| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: No Gutenberg? - Choose Where to Use the Block Editor or the Classic Editor |
| 4 |
* Plugin URI: https://servicios.ayudawp.com/ |
| 5 |
* Description: Complete elimination of Gutenberg Block Editor, FSE Global Styles, Block Widgets, Patterns, and WooCommerce blocks. Get back to the reliable Classic Editor with zero block-related overhead. |
| 6 |
* Version: 2.3.2 |
| 7 |
* Author: Fernando Tellado |
| 8 |
* Author URI: https://ayudawp.com/ |
| 9 |
* |
| 10 |
* @package No Gutenberg |
| 11 |
* License: GPL2+ |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Text Domain: no-gutenberg |
| 14 |
* Domain Path: /languages |
| 15 |
* Requires at least: 6.1 |
| 16 |
* Requires PHP: 7.4 |
| 17 |
* |
| 18 |
* No Gutenberg plugin is free software: you can redistribute it and/or modify |
| 19 |
* it under the terms of the GNU General Public License as published by |
| 20 |
* the Free Software Foundation, either version 2 of the License, or |
| 21 |
* any later version. |
| 22 |
* |
| 23 |
* No Gutenberg plugin is distributed in the hope that it will be useful, |
| 24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 |
* GNU General Public License for more details. |
| 27 |
* |
| 28 |
* You should have received a copy of the GNU General Public License |
| 29 |
* along with No Gutenberg. If not, see https://www.gnu.org/licenses/gpl-2.0.html |
| 30 |
*/ |
| 31 |
|
| 32 |
defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); |
| 33 |
|
| 34 |
/** |
| 35 |
* Plugin paths. |
| 36 |
*/ |
| 37 |
define( 'AYUDAWP_NO_GUTENBERG_FILE', __FILE__ ); |
| 38 |
define( 'AYUDAWP_NO_GUTENBERG_DIR', plugin_dir_path( __FILE__ ) ); |
| 39 |
define( 'AYUDAWP_NO_GUTENBERG_URL', plugin_dir_url( __FILE__ ) ); |
| 40 |
|
| 41 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-options.php'; |
| 42 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-core.php'; |
| 43 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-notices.php'; |
| 44 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-editor-switch.php'; |
| 45 |
|
| 46 |
if ( is_admin() ) { |
| 47 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-status.php'; |
| 48 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-promo-banner.php'; |
| 49 |
require_once AYUDAWP_NO_GUTENBERG_DIR . 'includes/class-no-gutenberg-settings.php'; |
| 50 |
} |
| 51 |
|
| 52 |
// Initialize the plugin. |
| 53 |
AyudaWP_No_Gutenberg::init(); |
| 54 |
AyudaWP_No_Gutenberg_Notices::init(); |
| 55 |
AyudaWP_No_Gutenberg_Editor_Switch::init(); |
| 56 |
|
| 57 |
if ( is_admin() ) { |
| 58 |
AyudaWP_No_Gutenberg_Settings::init(); |
| 59 |
|
| 60 |
// Carry an older configuration over after an automatic update, which never |
| 61 |
// fires the activation hook below. |
| 62 |
add_action( 'admin_init', array( 'AyudaWP_No_Gutenberg_Options', 'maybe_upgrade' ), 1 ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Plugin activation hook - display notice about successful activation |
| 67 |
*/ |
| 68 |
register_activation_hook( __FILE__, 'ayudawp_no_gutenberg_activation' ); |
| 69 |
|
| 70 |
/** |
| 71 |
* Set a transient to show the activation notice |
| 72 |
*/ |
| 73 |
function ayudawp_no_gutenberg_activation() { |
| 74 |
set_transient( 'ayudawp_no_gutenberg_activated', true, 60 ); |
| 75 |
|
| 76 |
AyudaWP_No_Gutenberg_Options::install(); |
| 77 |
|
| 78 |
// WP-CLI activates with is_admin() false, so the status class may not be |
| 79 |
// loaded here. |
| 80 |
if ( class_exists( 'AyudaWP_No_Gutenberg_Status' ) ) { |
| 81 |
AyudaWP_No_Gutenberg_Status::flush_content_cache(); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Add action links to plugin page |
| 87 |
* |
| 88 |
* @param array $links Plugin action links. |
| 89 |
* @return array |
| 90 |
*/ |
| 91 |
function ayudawp_no_gutenberg_action_links( $links ) { |
| 92 |
$settings_link = '<a href="' . esc_url( admin_url( 'options-general.php?page=' . AyudaWP_No_Gutenberg_Options::PAGE_SLUG ) ) . '">' . esc_html__( 'Settings', 'no-gutenberg' ) . '</a>'; |
| 93 |
$support_link = '<a href="https://servicios.ayudawp.com/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Support', 'no-gutenberg' ) . '</a>'; |
| 94 |
|
| 95 |
array_unshift( $links, $settings_link, $support_link ); |
| 96 |
|
| 97 |
return $links; |
| 98 |
} |
| 99 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'ayudawp_no_gutenberg_action_links' ); |
| 100 |
|