Initial commit xmarticaims

This commit is contained in:
2026-11-02 10:26:32 -06:00
commit e74236f5c1
9764 changed files with 2880647 additions and 0 deletions
@@ -0,0 +1,71 @@
<?php
/**
* Load lite-specific scripts here.
*
* @package WPCode
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'admin_enqueue_scripts', 'wpcode_admin_scripts_global_lite' );
add_action( 'admin_head', 'wpcode_listen_for_deploy_message' );
/**
* Load version-specific global scripts.
*
* @return void
*/
function wpcode_admin_scripts_global_lite() {
// Don't load global admin scripts if headers & footers mode is enabled.
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
return;
}
wpcode_admin_scripts_global();
}
/**
* This is loaded after the plugin is activated and if the installation process was initiated
* from the WPCode Library site it will redirect the user to the appropriate page to continue
* that process.
*
* @return void
*/
function wpcode_listen_for_deploy_message() {
// Load this only in the plugins list.
$screen = get_current_screen();
$screens = array(
'plugins',
'plugin-install',
);
if ( ! isset( $screen->id ) || ! in_array( $screen->id, $screens, true ) ) {
return;
}
$click_page = add_query_arg(
array(
'page' => 'wpcode-click',
),
admin_url( 'admin.php' )
)
?>
<script>
if ( window.opener ) {
window.opener.postMessage(
'wpcode-plugin-installed',
'<?php echo esc_url( wpcode()->library_auth->library_url ); ?>'
);
}
window.addEventListener(
'message',
( event ) => {
if ( !event.isTrusted || '<?php echo esc_url( wpcode()->library_auth->library_url ); ?>' !== event.origin || 'wpcode-show-connect' !== event.data ) {
return;
}
window.location.href = '<?php echo esc_url( $click_page ); ?>&message=wpcode-deploy';
},
false
);
</script>
<?php
}
@@ -0,0 +1,116 @@
<?php
/**
* Lite-specific admin page loader.
* Extends the default pages with lite-specific items.
*
* @package WPCode
*/
/**
* Class WPCode_Admin_Page_Loader_Lite.
*/
class WPCode_Admin_Page_Loader_Lite extends WPCode_Admin_Page_Loader {
/**
* Load menu items from parent class and add class-specific ones.
*
* @return void
*/
public function hooks() {
parent::hooks();
add_action( 'admin_menu', array( $this, 'add_upgrade_menu_item' ), 40 );
add_action( 'admin_head', array( $this, 'adjust_pro_menu_item_class' ) );
add_action( 'admin_head', array( $this, 'admin_menu_styles' ), 11 );
}
/**
* Require lite-specific files.
*
* @return void
*/
public function require_files() {
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/trait-wpcode-library-refresh-button.php';
parent::require_files();
}
/**
* Add lite-specific upgrade to pro menu item.
*
* @return void
*/
public function add_upgrade_menu_item() {
add_submenu_page(
'wpcode',
esc_html__( 'Upgrade to Pro', 'insert-headers-and-footers' ),
esc_html__( 'Upgrade to Pro', 'insert-headers-and-footers' ),
'wpcode_edit_snippets',
esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'wpcode-admin', 'admin-side-menu' ) )
);
}
/**
* Add the PRO badge to left sidebar menu item.
*
* @since 1.7.8
*/
public function adjust_pro_menu_item_class() {
global $submenu;
// Bail if plugin menu is not registered.
if ( ! isset( $submenu['wpcode'] ) ) {
return;
}
$upgrade_link_position = key(
array_filter(
$submenu['wpcode'],
static function ( $item ) {
return strpos( $item[2], 'https://wpcode.com/lite' ) !== false;
}
)
);
// Bail if "Upgrade to Pro" menu item is not registered.
if ( is_null( $upgrade_link_position ) ) {
return;
}
$screen = get_current_screen();
// Let's make sure we have an ID and the link is set in the menu.
if ( isset( $screen->id ) && isset( $submenu['wpcode'][ $upgrade_link_position ][2] ) ) {
// Let's clean up the screen id a bit.
$screen_id = str_replace(
array(
'code-snippets_page_',
'toplevel_page_',
),
'',
$screen->id
);
$submenu['wpcode'][ $upgrade_link_position ][2] = str_replace( 'wpcode-admin', $screen_id, $submenu['wpcode'][ $upgrade_link_position ][2] );
}
// Prepare a HTML class.
// phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
if ( isset( $submenu['wpcode'][ $upgrade_link_position ][4] ) ) {
$submenu['wpcode'][ $upgrade_link_position ][4] .= ' wpcode-sidebar-upgrade-pro';
} else {
$submenu['wpcode'][ $upgrade_link_position ][] = 'wpcode-sidebar-upgrade-pro';
}
// phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited
}
/**
* Output inline styles for the admin menu.
*/
public function admin_menu_styles() {
$styles = 'a.wpcode-sidebar-upgrade-pro { background-color: #59A56D !important; color: #fff !important; font-weight: 600 !important; }';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
printf( '<style>%s</style>', $styles );
}
}
@@ -0,0 +1,267 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WPCode Connect.
*
* WPCode Connect is our service that makes it easy to upgrade to WPCode Pro
* without having to manually install the WPCode Pro plugin.
*
* @since 2.0.9
*/
class WPCode_Connect {
/**
* Constructor.
*
* @since 2.0.9
*/
public function __construct() {
$this->hooks();
}
/**
* Hooks.
*
* @since 2.0.9
*/
public function hooks() {
add_action( 'wpcode_admin_page_content_wpcode-settings', array( $this, 'settings_enqueues' ) );
add_action( 'wp_ajax_wpcode_connect_url', array( $this, 'generate_url' ) );
add_action( 'wp_ajax_nopriv_wpcode_connect_process', array( $this, 'process' ) );
}
/**
* Settings page enqueues.
*
* @since 2.0.9
*/
public function settings_enqueues() {
$admin_asset_file = WPCODE_PLUGIN_PATH . 'build/connect.asset.php';
if ( ! file_exists( $admin_asset_file ) ) {
return;
}
$asset = require $admin_asset_file;
wp_enqueue_script( 'wpcode-connect-js', WPCODE_PLUGIN_URL . 'build/connect.js', $asset['dependencies'], $asset['version'], true );
}
/**
* Generate and return the WPCode Connect URL.
*
* @since 2.0.9
*/
public function generate_url() {
// Run a security check.
check_ajax_referer( 'wpcode_admin' );
// Check for permissions.
if ( ! current_user_can( 'install_plugins' ) ) {
wp_send_json_error( array( 'message' => esc_html__( 'You are not allowed to install plugins.', 'insert-headers-and-footers' ) ) );
}
$key = ! empty( $_POST['key'] ) ? sanitize_text_field( wp_unslash( $_POST['key'] ) ) : '';
if ( empty( $key ) ) {
wp_send_json_error( array( 'message' => esc_html__( 'Please enter your license key to connect.', 'insert-headers-and-footers' ) ) );
}
if ( class_exists( 'WPCode_Premium' ) ) {
wp_send_json_error( array( 'message' => esc_html__( 'Only the Lite version can be upgraded.', 'insert-headers-and-footers' ) ) );
}
// Verify pro version is not installed.
$active = activate_plugin( 'wpcode-premium/wpcode.php', false, false, true );
if ( ! is_wp_error( $active ) ) {
update_option( 'wpcode_install', 1 ); // Run install routines.
// Deactivate Lite.
$plugin = plugin_basename( WPCODE_FILE );
deactivate_plugins( $plugin );
do_action( 'wpcode_plugin_deactivated', $plugin );
wp_send_json_success(
array(
'message' => esc_html__( 'WPCode Pro is installed but not activated.', 'insert-headers-and-footers' ),
'reload' => true,
)
);
}
// Generate URL.
$oth = hash( 'sha512', wp_rand() );
$hashed_oth = hash_hmac( 'sha512', $oth, wp_salt() );
update_option( 'wpcode_connect_token', $oth );
update_option( 'wpcode_connect', $key );
$version = WPCODE_VERSION;
$endpoint = admin_url( 'admin-ajax.php' );
$redirect = admin_url( 'admin.php?page=wpcode-settings' );
$url = add_query_arg(
array(
'key' => $key,
'oth' => $hashed_oth,
'endpoint' => $endpoint,
'version' => $version,
'siteurl' => admin_url(),
'homeurl' => home_url(),
'redirect' => rawurldecode( base64_encode( $redirect ) ), // phpcs:ignore
'v' => 2,
'php' => phpversion(),
'wp' => get_bloginfo( 'version' ),
),
'https://upgrade.wpcode.com/'
);
wp_send_json_success(
array(
'url' => $url,
'back_url' => add_query_arg(
array(
'action' => 'wpcode_connect',
'oth' => $oth,
),
$endpoint
),
)
);
}
/**
* Process WPCode Connect.
*
* @since 2.0.9
*/
public function process() {
$error = esc_html__( 'There was an error while installing an upgrade. Please download the plugin from wpcode.com and install it manually.', 'insert-headers-and-footers' );
// Verify params present (oth & download link).
$post_oth = ! empty( $_REQUEST['oth'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['oth'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
$post_url = ! empty( $_REQUEST['file'] ) ? esc_url_raw( wp_unslash( $_REQUEST['file'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
if ( empty( $post_oth ) || empty( $post_url ) ) {
wp_send_json_error( $error );
}
// Verify oth.
$oth = get_option( 'wpcode_connect_token' );
if ( hash_hmac( 'sha512', $oth, wp_salt() ) !== $post_oth ) {
wp_send_json_error( $error );
}
// Delete so cannot replay.
delete_option( 'wpcode_connect_token' );
// Set the current screen to avoid undefined notices.
set_current_screen( 'wpcode_page_wpcode-settings' );
// Prepare variables.
$url = esc_url_raw(
add_query_arg(
array( 'page' => 'wpcode-settings' ),
admin_url( 'admin.php' )
)
);
// Verify pro not activated.
if ( class_exists( 'WPCode_Premium' ) ) {
wp_send_json_success( esc_html__( 'Plugin installed & activated.', 'insert-headers-and-footers' ) );
}
// Verify pro not installed.
$active = activate_plugin( 'wpcode-premium/wpcode.php', $url, false, true );
if ( ! is_wp_error( $active ) ) {
$plugin = plugin_basename( WPCODE_FILE );
deactivate_plugins( $plugin );
do_action( 'wpcode_plugin_deactivated', $plugin );
wp_send_json_success( esc_html__( 'Plugin installed & activated.', 'insert-headers-and-footers' ) );
}
$creds = request_filesystem_credentials( $url, '', false, false, null );
// Check for file system permissions.
if ( false === $creds || ! WP_Filesystem( $creds ) ) {
wp_send_json_error(
esc_html__( 'There was an error while installing an upgrade. Please check file system permissions and try again. Also, you can download the plugin from wpcode.com and install it manually.', 'insert-headers-and-footers' )
);
}
/*
* We do not need any extra credentials if we have gotten this far, so let's install the plugin.
*/
// Do not allow WordPress to search/download translations, as this will break JS output.
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
wpcode_require_upgrader();
// Create the plugin upgrader with our custom skin.
$installer = new Plugin_Upgrader( new WPCode_Skin() );
// Error check.
if ( ! method_exists( $installer, 'install' ) ) {
wp_send_json_error( $error );
}
// Check license key.
$key = get_option( 'wpcode_connect', false );
if ( empty( $key ) ) {
wp_send_json_error(
new WP_Error(
'403',
esc_html__( 'No key provided.', 'insert-headers-and-footers' )
)
);
}
$installer->install( $post_url ); // phpcs:ignore
// Flush the cache and return the newly installed plugin basename.
wp_cache_flush();
$plugin_basename = $installer->plugin_info();
if ( $plugin_basename ) {
// Deactivate the lite version first.
$plugin = plugin_basename( WPCODE_FILE );
deactivate_plugins( $plugin );
do_action( 'wpcode_plugin_deactivated', $plugin );
// Activate the plugin silently.
$activated = activate_plugin( $plugin_basename, '', false, true );
if ( ! is_wp_error( $activated ) ) {
add_option( 'wpcode_install', 1 );
wp_send_json_success( esc_html__( 'Plugin installed & activated.', 'insert-headers-and-footers' ) );
} else {
// Reactivate the lite plugin if pro activation failed.
activate_plugin( plugin_basename( WPCODE_FILE ), '', false, true );
wp_send_json_error( esc_html__( 'Pro version installed but needs to be activated on the Plugins page inside your WordPress admin.', 'insert-headers-and-footers' ) );
}
}
wp_send_json_error( $error );
}
}
new WPCode_Connect();
@@ -0,0 +1,328 @@
<?php
/**
* Class used for the lite-specific metabox.
*
* @package WPCode
*/
/**
* Class WPCode_Metabox_Snippets_Lite.
*/
class WPCode_Metabox_Snippets_Lite extends WPCode_Metabox_Snippets {
use WPCode_Revisions_Display_Lite;
/**
* Override the header tab content to make it specific to this class.
*
* @param WP_Post $post The post object.
*
* @return void
*/
public function output_tab_header( $post ) {
$this->form_for_scripts(
__( 'Header', 'insert-headers-and-footers' )
);
}
/**
* Override the footer tab content to make it specific to this class.
*
* @param WP_Post $post The post object.
*
* @return void
*/
public function output_tab_footer( $post ) {
$this->form_for_scripts(
__( 'Footer', 'insert-headers-and-footers' )
);
}
/**
* Override the body tab content to make it specific to this class.
*
* @param WP_Post $post The post object.
*
* @return void
*/
public function output_tab_body( $post ) {
$this->form_for_scripts(
__( 'Body', 'insert-headers-and-footers' )
);
}
/**
* Override the code tab content to make it specific to this class.
*
* @param WP_Post $post The post object.
*
* @return void
*/
public function output_tab_code( $post ) {
?>
<div class="wpcode-blur-area">
<p>
<?php esc_html_e( 'Choose the snippets you want to run on this page. Please note: only active snippets will be executed.', 'insert-headers-and-footers' ); ?>
</p>
<div class="wpcode-metabox-snippets">
<div id="wpcode-snippet-chooser">
<h3>
<?php esc_html_e( 'Select snippets', 'insert-headers-and-footers' ); ?>
<button class="wpcode-button-just-icon wpcode-drawer-toggle" id="wpcode-close-drawer">
<?php wpcode_icon( 'close' ); ?>
</button>
</h3>
<div class="wpcode-snippets-search">
<input type="text" id="wpcode-search-snippets" class="wpcode-input-text" placeholder="<?php esc_attr_e( 'Search snippets', 'insert-headers-and-footers' ); ?>"/>
<span class="wpcode-loading-spinner" id="wpcode-chooser-spinner"></span>
</div>
<div class="wpcode-chooser-fixed-height">
<div id="wpcode-choose-snippets"></div>
<div class="wpcode-choose-actions">
<button type="button" class="wpcode-button wpcode-button-secondary" id="wpcode-metabox-load-more"><?php esc_html_e( 'Load more snippets', 'insert-headers-and-footers' ); ?></button>
</div>
</div>
</div>
<div class="wpcode-picked-snippets-area">
<h3>
<button class="wpcode-button wpcode-drawer-toggle" id="wpcode-add-snippet-toggle" type="button">
<?php esc_html_e( '+ Choose Snippet', 'insert-headers-and-footers' ); ?>
</button>
</h3>
<div id="wpcode-picked-snippets">
<div class="wpcode-list-item wpcode-selected-snippet-item wpcode-list-item-has-pill">
<h3>Show site currency</h3>
<label>Page location</label>
<select>
<option>Insert After Post</option>
</select>
</div>
<div class="wpcode-list-item wpcode-selected-snippet-item wpcode-list-item-has-pill">
<h3>Banner Ad</h3>
<label>Page location</label>
<select>
<option>Insert Before Post</option>
</select>
</div>
<div class="wpcode-list-item wpcode-selected-snippet-item wpcode-list-item-has-pill">
<h3>Subscribe Reminder</h3>
<label>Page location</label>
<select>
<option>Insert Before Content</option>
</select>
</div>
<div class="wpcode-list-item wpcode-selected-snippet-item wpcode-list-item-has-pill">
<h3>Event Countdown</h3>
<label>Page location</label>
<select>
<option>Insert After Post</option>
</select>
</div>
<div class="wpcode-list-item wpcode-selected-snippet-item wpcode-list-item-has-pill">
<h3>Banner Ad 2</h3>
<label>Page location</label>
<select>
<option>Insert After Content</option>
</select>
</div>
<div class="wpcode-list-item wpcode-selected-snippet-item wpcode-list-item-has-pill">
<h3>Free Download Button</h3>
<label>Page location</label>
<select>
<option>Insert After Post</option>
</select>
</div>
</div>
</div>
</div>
</div>
<?php
echo WPCode_Admin_Page::get_upsell_box( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
__( 'Page Scripts is a Pro Feature', 'insert-headers-and-footers' ),
sprintf(
'<p>%s</p>',
esc_html__( 'While you can always use global snippets, in the PRO version you can easily add page-specific scripts and snippets directly from the post edit screen.', 'insert-headers-and-footers' )
),
array(
'text' => esc_html__( 'Upgrade to Pro and Unlock Page Scripts', 'insert-headers-and-footers' ),
'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'post-editor-metabox', 'custom-snippets', 'upgrade-to-pro' ) ),
),
array(
'text' => esc_html__( 'Learn more about all the features', 'insert-headers-and-footers' ),
'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'post-editor-metabox', 'custom-snippets', 'features' ) ),
)
);
}
/**
* Get the markup for a form using a disabled CodeMirror instance (to avoid loading a script that won't be used).
*
* @param string $label The label for this tab section.
*
* @return void
*/
public function form_for_scripts( $label ) {
wp_enqueue_style( 'code-editor' );
?>
<div class="wpcode-blur-area">
<p>
<?php
printf(
// Translators: placeholder for the name of the section (header or footer).
esc_html__( 'Add scripts below to the %s section of this page.', 'insert-headers-and-footers' ),
esc_html( $label )
);
?>
</p>
<p>
<label>
<input type="checkbox"/>
<?php
printf(
// Translators: placeholder for the name of the section (header or footer).
esc_html__( 'Disable global %s scripts on this page', 'insert-headers-and-footers' ),
esc_html( $label )
);
?>
</label>
</p>
<div class="wpcode-input-row">
<label>
<?php
printf(
// Translators: placeholder for the name of the section (header or footer).
esc_html__( '%s - any device type', 'insert-headers-and-footers' ),
esc_html( $label )
);
?>
</label>
<div class="wpcode-smart-tags">
<button class="wpcode-smart-tags-toggle">
<?php wpcode_icon( 'tags', 20, 16, '0 0 20 16' ); ?>
<span class="wpcode-text-default">
<?php esc_html_e( 'Show Smart Tags', 'insert-headers-and-footers' ); ?>
</span>
</button>
</div>
<div class="CodeMirror cm-s-default CodeMirror-wrap">
<div class="CodeMirror-vscrollbar" style="width: 18px; pointer-events: none;">
<div style="min-width: 1px; height: 0;"></div>
</div>
<div class="CodeMirror-hscrollbar" style="height: 18px; pointer-events: none;">
<div style="height: 100%; min-height: 1px; width: 0;"></div>
</div>
<div class="CodeMirror-scrollbar-filler"></div>
<div class="CodeMirror-gutter-filler"></div>
<div class="CodeMirror-scroll" tabindex="-1">
<div class="CodeMirror-sizer" style="margin-left: 50px; margin-bottom: 0; border-right-width: 30px; min-height: 165px; padding-right: 0; padding-bottom: 0;">
<div style="position: relative; top: 0;">
<div class="CodeMirror-lines" role="presentation">
<div role="presentation" style="position: relative; outline: none;">
<div class="CodeMirror-measure"></div>
<div class="CodeMirror-measure"></div>
<div style="position: relative; z-index: 1;"></div>
<div class="CodeMirror-cursors"></div>
<div class="" role="presentation" tabindex="0" style="">
<div class="CodeMirror-activeline" style="position: relative;">
<div class="CodeMirror-activeline-background CodeMirror-linebackground"></div>
<div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: -46px; width: 46px;"></div>
<div class="CodeMirror-gutter-wrapper CodeMirror-activeline-gutter" style="left: -46px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 16px; width: 21px;">
1
</div>
</div>
<pre class="CodeMirror-line" role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket CodeMirror-matchingtag">&lt;</span><span class="cm-tag CodeMirror-matchingtag">script</span><span class=" CodeMirror-matchingtag"> </span><span class="cm-attribute CodeMirror-matchingtag">type</span><span class=" CodeMirror-matchingtag">=</span><span class="cm-string CodeMirror-matchingtag">"text/javascript"</span><span class="cm-tag cm-bracket CodeMirror-matchingtag">&gt;</span></span></pre>
</div>
<div style="position: relative;">
<div class="CodeMirror-gutter-wrapper" style="left: -46px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 16px; width: 21px;">
2
</div>
</div>
<pre class="CodeMirror-line" role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation"> </span><span class="cm-variable">console</span>.<span class="cm-property">log</span>( <span class="cm-string">'header'</span> );</span></pre>
</div>
<div style="position: relative;">
<div class="CodeMirror-gutter-wrapper" style="left: -46px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 16px; width: 21px;">
3
</div>
</div>
<pre class="CodeMirror-line" role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket CodeMirror-matchingtag">&lt;/</span><span class="cm-tag CodeMirror-matchingtag">script</span><span class="cm-tag cm-bracket CodeMirror-matchingtag">&gt;</span></span></pre>
</div>
<div style="position: relative;">
<div class="CodeMirror-gutter-wrapper" style="left: -46px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 16px; width: 21px;">
4
</div>
</div>
<pre class="CodeMirror-line" role="presentation"><span role="presentation" style="padding-right: 0.1px;"></pre>
</div>
<div style="position: relative;">
<div class="CodeMirror-gutter-wrapper" style="left: -46px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 16px; width: 21px;">
5
</div>
</div>
<pre class="CodeMirror-line" role="presentation"><span role="presentation" style="padding-right: 0.1px;"></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="position: absolute; height: 30px; width: 1px; border-bottom: 0 solid transparent; top: 165px;"></div>
<div class="CodeMirror-gutters" style="height: 195px;">
<div class="CodeMirror-gutter CodeMirror-lint-markers"></div>
<div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 29px;"></div>
</div>
</div>
</div>
</div>
</div>
<?php
echo WPCode_Admin_Page::get_upsell_box( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
__( 'Page Scripts is a Pro Feature', 'insert-headers-and-footers' ),
sprintf(
'<p>%s</p>',
esc_html__( 'While you can always use global snippets, in the PRO version you can easily add page-specific scripts and snippets directly from the post edit screen.', 'insert-headers-and-footers' )
),
array(
'text' => esc_html__( 'Upgrade to Pro and Unlock Page Scripts', 'insert-headers-and-footers' ),
'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'post-editor-metabox', 'main-' . sanitize_title( $label ), 'upgrade-to-pro' ) ),
),
array(
'text' => esc_html__( 'Learn more about all the features', 'insert-headers-and-footers' ),
'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'post-editor-metabox', 'main-' . sanitize_title( $label ), 'features' ) ),
)
);
}
/**
* Override the revisions tab content to make it specific to this class.
*
* @param WP_Post $post The post object.
*
* @return void
*/
public function output_tab_revisions( $post ) {
printf(
'<p>%s</p>',
esc_html__( 'As you make changes to your page scripts and save, you will get a list of previous versions with all the changes made in each revision. You can compare revisions to the current version or see changes as they have been saved by going through each revision. Any of the revisions can then be restored as needed without interfering with your post/page.', 'insert-headers-and-footers' )
);
echo $this->code_revisions_list_with_notice( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
esc_html__( 'Code Revisions is a Pro Feature', 'insert-headers-and-footers' ),
sprintf(
'<p>%s</p>',
esc_html__( 'Upgrade to WPCode Pro today and start tracking revisions and see exactly who, when and which changes were made to your page scripts.', 'insert-headers-and-footers' )
),
array(
'text' => esc_html__( 'Upgrade to Pro and Unlock Revisions', 'insert-headers-and-footers' ),
'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'post-editor-metabox', 'revisions', 'upgrade-to-pro' ) ),
),
array(
'text' => esc_html__( 'Learn more about all the features', 'insert-headers-and-footers' ),
'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'post-editor-metabox', 'revisions', 'features' ) ),
)
);
}
}
@@ -0,0 +1,32 @@
<?php
/**
* WPCode Usage Tracking Lite
*
* @package WPCode
* @since 2.0.10
*/
/**
* Class WPCode_Usage_Tracking_Lite
*/
class WPCode_Usage_Tracking_Lite extends WPCode_Usage_Tracking {
/**
* Get the type for the request.
*
* @return string The plugin type.
* @since 2.0.10
*/
public function get_type() {
return 'lite';
}
/**
* Is the usage tracking enabled?
*
* @return bool
*/
public function is_enabled() {
return boolval( wpcode()->settings->get_option( 'usage_tracking' ) );
}
}
@@ -0,0 +1,158 @@
<?php
/**
* Lite-specific admin notices.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'admin_init', 'wpcode_maybe_add_library_connect_notice' );
add_action( 'wpcode_admin_page', 'wpcode_maybe_add_lite_top_bar_notice', 4 );
add_action( 'wpcode_admin_page_content_wpcode-headers-footers', 'wpcode_headers_footers_bottom_notice', 250 );
/**
* Show a prompt to connect to the WPCode Library to get access to more snippets.
*
* @return void
*/
function wpcode_maybe_add_library_connect_notice() {
if ( ! isset( $_GET['page'] ) || 0 !== strpos( $_GET['page'], 'wpcode' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
return;
}
if ( ! isset( wpcode()->library_auth ) || wpcode()->library_auth->has_auth() ) {
return;
}
// Don't show if in headers & footers mode only.
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
return;
}
$settings_url = add_query_arg(
array(
'page' => 'wpcode-settings',
),
admin_url( 'admin.php' )
);
$snippets_count = wpcode()->library->get_snippets_count();
// Translators: more here is used in the sense of "get access to more snippets" and gets replaced with the number of snippets if the library items are loaded correctly.
$more = $snippets_count > 0 ? $snippets_count : __( 'more', 'insert-headers-and-footers' );
WPCode_Notice::info(
sprintf(
// Translators: %1$s and %2$s add a link to the settings page. %3$s and %4$s make the text bold. %6$s is replaced with the number of snippets and %5$s adds a "new" icon.
__( '%5$s%1$sConnect to the WPCode Library%2$s to get access to %3$s%6$s FREE snippets%4$s!', 'insert-headers-and-footers' ),
'<a href="' . $settings_url . '" class="wpcode-start-auth">',
'</a>',
'<strong>',
'</strong>',
'<span class="wpcode-icon-new">&nbsp;NEW!</span>',
$more
),
array(
'dismiss' => WPCode_Notice::DISMISS_GLOBAL,
'slug' => 'wpcode-library-connect-lite',
)
);
}
/**
* Add a notice to consider more features with offer.
*
* @return void
*/
function wpcode_maybe_add_lite_top_bar_notice() {
// Only add this to the WPCode pages.
if ( ! isset( $_GET['page'] ) || 0 !== strpos( $_GET['page'], 'wpcode' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
return;
}
// Don't show in H&F mode.
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
return;
}
$screen = get_current_screen();
if ( isset( $screen->id ) && false !== strpos( $screen->id, 'code-snippets_page_wpcode-' ) ) {
$screen = str_replace( 'code-snippets_page_wpcode-', '', $screen->id );
} else {
$screen = 'snippets-list';
}
$upgrade_url = wpcode_utm_url(
'https://wpcode.com/lite/',
'top-notice',
$screen
);
WPCode_Notice::top(
sprintf(
// Translators: %1$s and %2$s add a link to the upgrade page. %3$s and %4$s make the text bold.
__( '%3$sYou\'re using WPCode Lite%4$s. To unlock more features consider %1$supgrading to Pro%2$s.', 'insert-headers-and-footers' ),
'<a href="' . $upgrade_url . '" target="_blank" rel="noopener noreferrer">',
'</a>',
'<strong>',
'</strong>'
),
array(
'dismiss' => WPCode_Notice::DISMISS_USER,
'slug' => 'consider-upgrading',
)
);
}
/**
* Show a notice with more features at the bottom of the Headers & Footers page.
*
* @return void
*/
function wpcode_headers_footers_bottom_notice() {
// Don't show if in headers & footers mode only.
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
return;
}
// Don't show if other notices were already displayed on the page.
if ( ! empty( wpcode()->notice->notices ) ) {
return;
}
$html = '<h3>' . esc_html__( 'Get WPCode Pro and Unlock all the Powerful Features', 'insert-headers-and-footers' ) . '</h3>';
$html .= '<div class="wpcode-features-list">';
$html .= '<ul>';
$html .= '<li>' . esc_html__( 'Save & Reuse snippets in your private Cloud Library', 'insert-headers-and-footers' ) . '</li>';
$html .= '<li>' . esc_html__( 'Add page-specific scripts when editing a post/page.', 'insert-headers-and-footers' ) . '</li>';
$html .= '<li>' . esc_html__( 'Track all snippet changes with Advanced Code Revisions', 'insert-headers-and-footers' ) . '</li>';
$html .= '</ul>';
$html .= '<ul>';
$html .= '<li>' . esc_html__( 'Load snippets by device (mobile/desktop) with 1-click.', 'insert-headers-and-footers' ) . '</li>';
$html .= '<li>' . esc_html__( 'Easily insert and reuse content with Custom Shortcodes.', 'insert-headers-and-footers' ) . '</li>';
$html .= '<li>' . esc_html__( 'Precisely track eCommerce conversions for WooCommerce and EDD.', 'insert-headers-and-footers' ) . '</li>';
$html .= '</ul>';
$html .= '</div>';
$html .= sprintf(
'<p><a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a></p>',
wpcode_utm_url( 'https://wpcode.com/lite/', 'headers-footers', 'notice', 'get-wpcode-pro' ),
esc_html__( 'Get WPCode Pro Today and Unlock all the Powerful Features »', 'insert-headers-and-footers' )
);
$html .= '<p>';
$html .= sprintf(
// Translators: Placeholders make the text bold.
esc_html__( '%1$sBonus:%2$s WPCode Lite users get %3$s$50 off regular price%4$s, automatically applied at checkout', 'insert-headers-and-footers' ),
'<strong>',
'</strong>',
'<strong style="color:#59A56D;">',
'</strong>'
);
$html .= '</p>';
// Add our custom notice for this page.
WPCode_Notice::info(
$html,
array(
'slug' => 'ihaf-snippets',
'dismiss' => WPCode_Notice::DISMISS_USER,
)
);
// Display notice we just added so that scripts are loaded.
wpcode()->notice->display();
}