' . __( 'If you see this message after saving the snippet to the Woody Code Snippets plugin, please enable safe mode in the Woody plugin. Safe mode will allow you to continue working in the admin panel of your site and change the snippet in which you made a php error.', 'insert-php' ) . '';
$safe_mode_button .= '' . __( 'Enable Safe Mode', 'insert-php' ) . '';
return $message . $safe_mode_button;
}
);
/**
* Enables/Disable safe mode, in which the php code will not be executed.
*/
add_action(
'plugins_loaded',
function () {
if ( isset( $_GET['wbcr-php-snippets-safe-mode'] ) ) {
WINP_Helper::enable_safe_mode();
wp_safe_redirect( esc_url( remove_query_arg( [ 'wbcr-php-snippets-safe-mode' ] ) ) );
die();
}
if ( isset( $_GET['wbcr-php-snippets-disable-safe-mode'] ) ) {
WINP_Helper::disable_safe_mode();
wp_safe_redirect( esc_url( remove_query_arg( [ 'wbcr-php-snippets-disable-safe-mode' ] ) ) );
die();
}
},
- 1
);
/**
* Register product to SDK
*
* @param array $products Registered products.
* @return array
*/
function winp_sdk_register_products( $products ) {
$products[] = WINP_PLUGIN_FILE;
return $products;
}
/**
* About page metadata
*
* @return array
*/
function winp_sdk_about_page() {
return [
'location' => 'edit.php?post_type=wbcr-snippets',
'logo' => WINP_PLUGIN_URL . '/admin/assets/img/icon-256x256.png',
'review_link' => false,
'has_upgrade_menu' => false,
];
}
/**
* Register compatibility using SDK.
*
* @param array> $compatibilities All compatibilities.
*
* @return array> Registered compatibility.
*/
function winp_sdk_register_compatibility( $compatibilities ) {
$compatibilities['WoodyPro'] = [
'basefile' => defined( 'WASP_PLUGIN_FILE' ) ? WASP_PLUGIN_FILE : '',
'required' => '1.3.0',
];
return $compatibilities;
}
add_filter( 'themeisle_sdk_products', 'winp_sdk_register_products' );
add_filter( WINP_PLUGIN_NAMESPACE . '_about_us_metadata', 'winp_sdk_about_page' );
add_filter( 'themeisle_sdk_compatibilities/' . basename( WINP_PLUGIN_DIR ), 'winp_sdk_register_compatibility' );
// Register activation/deactivation hooks.
register_activation_hook(
WINP_PLUGIN_FILE,
function () {
global $winp_snippets_locations;
if ( ! isset( $winp_snippets_locations ) ) {
$winp_snippets_locations = new WINP_Insertion_Locations();
}
// Instantiate plugin for activation.
$plugin = new WINP_Plugin();
$plugin->activation_hook();
}
);
register_deactivation_hook(
WINP_PLUGIN_FILE,
function () {
global $winp_snippets_locations;
if ( ! isset( $winp_snippets_locations ) ) {
$winp_snippets_locations = new WINP_Insertion_Locations();
}
// Instantiate plugin for deactivation.
$plugin = new WINP_Plugin();
$plugin->deactivation_hook();
}
);
// Initialize on 'init' hook with priority 0 to avoid early translation loading (WP 6.7+)
add_action(
'init',
function () {
global $winp_snippets_locations;
$winp_snippets_locations = new WINP_Insertion_Locations();
try {
new WINP_Plugin();
} catch ( Exception $exception ) {
// Plugin wasn't initialized due to an error
define( 'WINP_PLUGIN_THROW_ERROR', true );
$wbcr_plugin_error_func = function () use ( $exception ) {
$error = sprintf( 'The %s plugin has stopped. Error: %s Code: %s', 'Woody Ad Snippets', $exception->getMessage(), $exception->getCode() );
echo '';
};
add_action( 'admin_notices', $wbcr_plugin_error_func );
add_action( 'network_admin_notices', $wbcr_plugin_error_func );
}
},
0
);