This commit is contained in:
Javier Casares 2026-08-17 17:56:43 +00:00
commit 3a25585090
42 changed files with 1124 additions and 711 deletions

View file

@ -1,20 +1,19 @@
<?php
/**
* Plugin Name: Documentation Markdown (by ROBOTSTXT)
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-documentation-markdown
* Plugin URI: https://www.robotstxt.software/plugins/robotstxt-documentation-markdown/
* Description: Synchronizes Markdown documentation from GitHub repositories to WordPress pages and posts automatically.
* Version: 1.2.0
* Requires at least: 6.8
* Version: 1.2.1
* Requires at least: 4.2
* Requires PHP: 8.0
* Security: robotstxt@robotstxt.es
* Author: ROBOTSTXT
* Author URI: https://www.robotstxt.es/
* Author URI: https://www.robotstxt.software/
* Text Domain: robotstxt-documentation-markdown
* Domain Path: /languages
* License: GPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Gitea Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-documentation-markdown
* Primary Branch: main
* Update URI: https://www.robotstxt.software/plugins/robotstxt-documentation-markdown/
*
* @package RobotsTxt\DocumentationMarkdown
* @since 1.0.0
@ -26,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
// Define plugin constants.
define( 'ROBOTSTXT_DOCMD_VERSION', '1.2.0' );
define( 'ROBOTSTXT_DOCMD_VERSION', '1.2.1' );
define( 'ROBOTSTXT_DOCMD_PLUGIN_FILE', __FILE__ );
define( 'ROBOTSTXT_DOCMD_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ROBOTSTXT_DOCMD_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
@ -53,6 +52,7 @@ add_action( 'init', 'robotstxt_docmd_init' );
add_action( 'admin_menu', 'robotstxt_docmd_register_admin_menu' );
add_action( 'admin_enqueue_scripts', 'robotstxt_docmd_enqueue_admin_assets' );
add_action( 'admin_init', 'robotstxt_docmd_handle_admin_actions' );
add_action( 'admin_notices', 'robotstxt_docmd_admin_notice_manager_plugin' );
/**
* Plugin activation
@ -1046,6 +1046,10 @@ function robotstxt_docmd_render_settings_page() {
<?php robotstxt_docmd_render_admin_notices(); ?>
<?php if ( ! robotstxt_docmd_is_manager_active() ) : ?>
<?php robotstxt_docmd_render_manager_notice( false ); ?>
<?php endif; ?>
<form method="post" action="">
<?php wp_nonce_field( 'robotstxt_docmd_save_settings', 'robotstxt_docmd_nonce' ); ?>
@ -1671,6 +1675,65 @@ function robotstxt_docmd_debug_fix_crons() {
exit;
}
// Initialize ROBOTSTXT updater (auto-configures from plugin headers).
require_once __DIR__ . '/class-robotstxt-updater.php';
Robotstxt_Updater::init( __FILE__ );
/**
* Check whether the Manager (by ROBOTSTXT) plugin is active
*
* Updates for this plugin are delivered through the Manager plugin. This
* helper detects whether it is installed and active.
*
* @since 1.2.1
*
* @return bool True if Manager (by ROBOTSTXT) is active, false otherwise.
*/
function robotstxt_docmd_is_manager_active(): bool {
return defined( 'ROBOTSTXT_MANAGER_VERSION' );
}
/**
* Render the Manager (by ROBOTSTXT) recommendation notice
*
* Shared markup for the plugins list page (dismissible) and the plugin
* settings page (not dismissible). Only rendered when Manager is not active.
*
* @since 1.2.1
*
* @param bool $dismissible Whether the notice should be dismissible.
* @return void
*/
function robotstxt_docmd_render_manager_notice( bool $dismissible ): void {
echo '<div class="notice notice-warning' . ( $dismissible ? ' is-dismissible' : '' ) . '"><p>';
echo wp_kses(
sprintf(
/* translators: %s: Manager (by ROBOTSTXT) plugin URL. */
__( 'To receive automatic updates, the <a href="%s">Manager (by ROBOTSTXT)</a> plugin must be installed and active.', 'robotstxt-documentation-markdown' ),
esc_url( 'https://www.robotstxt.software/plugins/robotstxt-manager/' )
),
array(
'a' => array(
'href' => true,
),
)
);
echo '</p></div>';
}
/**
* Show the Manager (by ROBOTSTXT) notice on the plugins list page
*
* @since 1.2.1
*
* @return void
*/
function robotstxt_docmd_admin_notice_manager_plugin(): void {
global $pagenow;
if ( 'plugins.php' !== $pagenow ) {
return;
}
if ( ! current_user_can( 'edit_pages' ) || robotstxt_docmd_is_manager_active() ) {
return;
}
robotstxt_docmd_render_manager_notice( true );
}