$options['sa_element'],
'topspace' => $options['sa_topspace'],
'minscreenwidth' => $options['sa_minscreenwidth'],
'maxscreenwidth' => $options['sa_maxscreenwidth'],
'zindex' => $options['sa_zindex'],
'legacymode' => $options['sa_legacymode'],
'dynamicmode' => $options['sa_dynamicmode'],
'debugmode' => $options['sa_debugmode'],
'pushup' => $options['sa_pushup'],
'adminbar' => $options['sa_adminbar']
);
wp_enqueue_script('stickThis', plugins_url('/assets/js/stickThis.js', __FILE__), array( 'jquery' ), $versionNum, true);
wp_localize_script( 'stickThis', 'sticky_anything_engage', $script_vars );
}
}
/**
* --- ADD LINK TO SETTINGS PAGE TO SIDEBAR ------------------------------------------------------------
*/
if (!function_exists('sticky_anything_menu')) {
function sticky_anything_menu() {
add_options_page( 'Sticky Menu (or Anything!) Configuration', 'Sticky Menu (or Anything!)', 'manage_options', 'stickyanythingmenu', 'sticky_anything_config_page' );
}
}
/**
* --- ADD LINK TO SETTINGS PAGE TO PLUGIN ------------------------------------------------------------
*/
if (!function_exists('sticky_anything_settings_link')) {
function sticky_anything_settings_link($links) {
$settings_link = 'Settings ';
array_unshift($links, $settings_link);
$links[] = 'Get PRO ';
return $links;
}
}
function sticky_plugin_meta_links($links, $file) {
$support_link = 'Support ';
if ($file == plugin_basename(__FILE__)) {
$links[] = $support_link;
}
return $links;
} // sticky_plugin_meta_links
// additional powered by text in admin footer; only on Sticky page
function sticky_admin_footer_text($text) {
$screen = get_current_screen();
if ($screen->id != 'settings_page_stickyanythingmenu') {
return;
}
$plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
$text = 'WP Sticky v' . $plugin_data['version'] . ' by WebFactory Ltd . Please rate the plugin ★★★★★ to help us spread the word. Thank you! ';
return $text;
} // admin_footer_text
/**
* --- THE WHOLE ADMIN SETTINGS PAGE -------------------------------------------------------------------
*/
if (!function_exists('sticky_anything_config_page')) {
function sticky_anything_config_page() {
// Retrieve plugin configuration options from database
$sticky_anything_options = get_option( 'sticky_anything_options' );
?>
'sticky_hide_review_notification', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
$dismiss_url = wp_nonce_url($dismiss_url, 'sticky_hide_review_notification');
?>
Help us keep Sticky Menu updated & free!
Glad to see Sticky is helping you make things stick 😎 Please help other users learn about Sticky by rating it. It takes only a few clicks but it keeps the plugin free, updated and supported! Thank you!
I want to rate & keep Sticky Menu free! I already rated it
'.esc_html__('Settings Updated.','sticky-menu-or-anything-on-scroll').'
';
}
}
if ( isset( $_GET['message'] )) {
if ($sticky_anything_options['sa_element'] == '') {
$warnings = true;
}
}
if ( (!is_numeric(@$sticky_anything_options['sa_topspace'])) && (@$sticky_anything_options['sa_topspace'] != '')) {
// Top space is not empty and has bad value
$warnings = true;
}
if ( (!is_numeric($sticky_anything_options['sa_minscreenwidth'])) && ($sticky_anything_options['sa_minscreenwidth'] != '')) {
// Minimum width is not empty and has bad value
$warnings = true;
}
if ( (!is_numeric($sticky_anything_options['sa_maxscreenwidth'])) && ($sticky_anything_options['sa_maxscreenwidth'] != '')) {
// Maximum width is not empty and has bad value
$warnings = true;
}
if ( ($sticky_anything_options['sa_minscreenwidth'] != '') && ($sticky_anything_options['sa_maxscreenwidth'] != '') && ( ($sticky_anything_options['sa_minscreenwidth']) >= ($sticky_anything_options['sa_maxscreenwidth']) ) ) {
// Minimum width is larger than the maximum width
$warnings = true;
}
if ((!is_numeric(@$sticky_anything_options['sa_zindex'])) && (@$sticky_anything_options['sa_zindex'] != '')) {
// Z-index is not empty and has bad value
$warnings = true;
}
// IF THERE ARE ERRORS, SHOW THEM
if ( $warnings == true ) {
echo '
'.esc_html__('Please review the current settings:','sticky-menu-or-anything-on-scroll').'
';
echo '
';
if ($sticky_anything_options['sa_element'] == '') {
sticky_wp_kses_wf(''.__('Sticky Element is a required field. If you do not want anything sticky, consider disabling the plugin.','sticky-menu-or-anything-on-scroll').' ');
}
if ( (!is_numeric($sticky_anything_options['sa_topspace'])) && ($sticky_anything_options['sa_topspace'] != '')) {
sticky_wp_kses_wf(''.__('Top Position has to be a number (do not include "px" or "pixels", or any other characters).','sticky-menu-or-anything-on-scroll').' ');
}
if ( (!is_numeric($sticky_anything_options['sa_minscreenwidth'])) && ($sticky_anything_options['sa_minscreenwidth'] != '')) {
sticky_wp_kses_wf(''.__('Minimum Screen Width has to be a number (do not include "px" or "pixels", or any other characters).','sticky-menu-or-anything-on-scroll').' ');
}
if ( (!is_numeric($sticky_anything_options['sa_maxscreenwidth'])) && ($sticky_anything_options['sa_maxscreenwidth'] != '')) {
sticky_wp_kses_wf(''.__('Maximum Screen Width has to be a number (do not include "px" or "pixels", or any other characters).','sticky-menu-or-anything-on-scroll').' ');
}
if ( ($sticky_anything_options['sa_minscreenwidth'] != '') && ($sticky_anything_options['sa_maxscreenwidth'] != '') && ( ($sticky_anything_options['sa_minscreenwidth']) >= ($sticky_anything_options['sa_maxscreenwidth']) ) ) {
sticky_wp_kses_wf(''.__('MAXIMUM screen width has to have a larger value than the MINIMUM screen width.','sticky-menu-or-anything-on-scroll').' ');
}
if ((!is_numeric($sticky_anything_options['sa_zindex'])) && ($sticky_anything_options['sa_zindex'] != '')) {
sticky_wp_kses_wf(''.__('Z-Index has to be a number (do not include any other characters).','sticky-menu-or-anything-on-scroll').' ');
}
echo ' ';
}
?>
';
include 'assets/sidebar.php';
echo '';
}
$plugin_url = plugin_dir_url(__FILE__);
?>
'stickyanythingmenu', 'message' => '1', 'tab' => $tabValue),
admin_url( 'options-general.php' )
)
);
exit;
}
}
/**
* --- ADD THE .CSS AND .JS TO ADMIN MENU --------------------------------------------------------------
*/
if (!function_exists('sticky_anything_styles')) {
function sticky_anything_styles($hook) {
// welcome pointer is shown on all pages except Sticky, only to admins, until dismissed
$pointers = sticky_get_pointers();
$dismissed_notices = sticky_get_dismissed_notices();
foreach ($dismissed_notices as $notice_name => $tmp) {
if ($tmp) {
unset($pointers[$notice_name]);
}
} // foreach
if (current_user_can('administrator') && !empty($pointers) && 'settings_page_stickyanythingmenu' != $hook) {
$pointers['_nonce_dismiss_notice'] = wp_create_nonce('sticky_dismiss_notice');
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-sticky-pointers', plugins_url('assets/js/sticky-admin-pointers.js', __FILE__), array('jquery'), 1, true);
wp_enqueue_script('wp-pointer');
wp_localize_script('wp-pointer', 'sticky_pointers', $pointers);
}
if ($hook != 'settings_page_stickyanythingmenu') {
return;
}
$sticky_anything_options = get_option( 'sticky_anything_options' );
wp_register_script('stickyAnythingAdminScript', plugins_url('/assets/js/sticky-anything-admin.js', __FILE__), array( 'jquery' ), '2.1.1');
wp_enqueue_script('stickyAnythingAdminScript');
wp_register_style('stickyAnythingAdminStyle', plugins_url('/assets/css/sticky-anything-admin.css', __FILE__) );
wp_enqueue_style('stickyAnythingAdminStyle');
wp_enqueue_style('wp-jquery-ui-dialog');
wp_enqueue_script('jquery-ui-dialog');
wp_enqueue_style('wp-color-picker');
wp_enqueue_script('wp-color-picker');
$js_vars = array(
'auto_open_pro_dialog' => empty($sticky_anything_options['sa_dismiss_upsell_auto_open']),
);
wp_localize_script('jquery-ui-dialog', 'wpsticky', $js_vars);
$sticky_anything_options['sa_dismiss_upsell_auto_open'] = true;
update_option('sticky_anything_options', $sticky_anything_options);
}
}
function sticky_anything_admin_footer() {
$screen = get_current_screen();
if ($screen->id != 'settings_page_stickyanythingmenu') {
return;
}
$out = '';
$out .= '';
$plugin_url = plugin_dir_url(__FILE__);
$out .= '
';
$out .= '
';
$out .= '';
$out .= 'Lifetime Single License ';
$out .= 'Lifetime Team License ';
$out .= 'Lifetime Agency License ';
$out .= ' ';
$out .= '';
$out .= '1 Site License ';
$out .= '3 Sites License ';
$out .= '100 Sites License ';
$out .= ' ';
$out .= '';
$out .= ' Install on Client Sites ';
$out .= ' Install on Client Sites ';
$out .= ' Install on Client Sites ';
$out .= ' ';
$out .= '';
$out .= ' White-Label Mode ';
$out .= ' White-Label Mode ';
$out .= ' White-Label Mode ';
$out .= ' ';
$out .= '';
$out .= ' One Time Payment ';
$out .= ' One Time Payment ';
$out .= ' One Time Payment ';
$out .= ' ';
$out .= '';
$out .= ' Lifetime Updates & Support ';
$out .= ' Lifetime Updates & Support ';
$out .= ' Lifetime Updates & Support ';
$out .= ' ';
$out .= '';
$out .= ' Priority email support ';
$out .= ' Priority email support ';
$out .= ' Priority email support ';
$out .= ' ';
$out .= '';
$out .= ' All Plugin Features ';
$out .= ' All Plugin Features ';
$out .= ' All Plugin Features ';
$out .= ' ';
$out .= '';
$out .= ' Unlimited Sticky Elements ';
$out .= ' Unlimited Sticky Elements ';
$out .= ' Unlimited Sticky Elements ';
$out .= ' ';
$out .= '';
$out .= ' Visual Elements Picker ';
$out .= ' Visual Elements Picker ';
$out .= ' Visual Elements Picker ';
$out .= ' ';
$out .= '';
$out .= ' Advanced Options & Effects ';
$out .= ' Advanced Options & Effects ';
$out .= ' Advanced Options & Effects ';
$out .= ' ';
$out .= '';
$out .= '20% discount BUY NOW $49 $39 -or-ONLY $5.99 /month ';
$out .= '40% discount BUY NOW $79 $49 ';
$out .= '$100 discount BUY NOW $199 $99 ';
$out .= ' ';
$out .= '
';
$out .= '
';
sticky_wp_kses_wf($out);
} // sticky_anything_admin_footer
function sticky_hide_review_notification() {
if (false == wp_verify_nonce(@$_GET['_wpnonce'], 'sticky_hide_review_notification')) {
wp_die('Please click back, reload the page and try again.');
}
$sticky_anything_options = get_option( 'sticky_anything_options' );
$sticky_anything_options['sa_hide_review_notification'] = true;
update_option('sticky_anything_options', $sticky_anything_options);
if (!empty($_GET['redirect'])) {
wp_safe_redirect(esc_url($_GET['redirect']));
} else {
wp_safe_redirect(admin_url('options-general.php?page=stickyanythingmenu'));
}
exit;
} // sticky_hide_review_notification
/**
* Returns all WP pointers
*
* @return array
*/
function sticky_get_pointers()
{
$pointers = array();
$pointers['welcome'] = array('target' => '#menu-settings', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for using the Sticky Menu (or Anything!) on Scroll plugin. Open Settings - Sticky Menu to make anything sticky.');
return $pointers;
} // sticky_get_pointers
/**
* Get all dismissed notices, or check for one specific notice.
*
* @param string $notice_name Optional. Check if specified notice is dismissed.
*
* @return bool|array
*/
function sticky_get_dismissed_notices($notice_name = '')
{
$notices = get_option('sticky_dismissed_notices', array());
if (empty($notice_name)) {
return $notices;
} else {
if (empty($notices[$notice_name])) {
return false;
} else {
return true;
}
}
} // sticky_get_dismissed_notices
/**
* Dismiss notice via AJAX call
*
* @return null
*/
function sticky_ajax_dismiss_notice()
{
check_ajax_referer('sticky_dismiss_notice');
if (empty($_POST['notice_name'])) {
wp_send_json_error('Notice name is undefined.');
} else {
$notice_name = substr(sanitize_key($_POST['notice_name']), 0, 64);
}
$notices = get_option('sticky_dismissed_notices', array());
$notices[$notice_name] = true;
update_option('sticky_dismissed_notices', $notices);
wp_send_json_success();
} // sticky_ajax_dismiss_notice
function sticky_anything_deactivate() {
delete_option('sticky_dismissed_notices');
$sticky_anything_options = get_option('sticky_anything_options');
unset($sticky_anything_options['sa_dismiss_upsell_auto_open']);
update_option('sticky_anything_options', $sticky_anything_options);
}
function sticky_wp_kses_wf($html)
{
add_filter('safe_style_css', function ($styles) {
$styles_wf = array(
'text-align',
'margin',
'color',
'float',
'border',
'background',
'background-color',
'border-bottom',
'border-bottom-color',
'border-bottom-style',
'border-bottom-width',
'border-collapse',
'border-color',
'border-left',
'border-left-color',
'border-left-style',
'border-left-width',
'border-right',
'border-right-color',
'border-right-style',
'border-right-width',
'border-spacing',
'border-style',
'border-top',
'border-top-color',
'border-top-style',
'border-top-width',
'border-width',
'caption-side',
'clear',
'cursor',
'direction',
'font',
'font-family',
'font-size',
'font-style',
'font-variant',
'font-weight',
'height',
'letter-spacing',
'line-height',
'margin-bottom',
'margin-left',
'margin-right',
'margin-top',
'overflow',
'padding',
'padding-bottom',
'padding-left',
'padding-right',
'padding-top',
'text-decoration',
'text-indent',
'vertical-align',
'width',
'display',
);
foreach ($styles_wf as $style_wf) {
$styles[] = $style_wf;
}
return $styles;
});
$allowed_tags = wp_kses_allowed_html('post');
$allowed_tags['input'] = array(
'type' => true,
'style' => true,
'class' => true,
'id' => true,
'checked' => true,
'disabled' => true,
'name' => true,
'size' => true,
'placeholder' => true,
'value' => true,
'data-*' => true,
'size' => true,
'disabled' => true
);
$allowed_tags['textarea'] = array(
'type' => true,
'style' => true,
'class' => true,
'id' => true,
'checked' => true,
'disabled' => true,
'name' => true,
'size' => true,
'placeholder' => true,
'value' => true,
'data-*' => true,
'cols' => true,
'rows' => true,
'disabled' => true,
'autocomplete' => true
);
$allowed_tags['select'] = array(
'type' => true,
'style' => true,
'class' => true,
'id' => true,
'checked' => true,
'disabled' => true,
'name' => true,
'size' => true,
'placeholder' => true,
'value' => true,
'data-*' => true,
'multiple' => true,
'disabled' => true
);
$allowed_tags['option'] = array(
'type' => true,
'style' => true,
'class' => true,
'id' => true,
'checked' => true,
'disabled' => true,
'name' => true,
'size' => true,
'placeholder' => true,
'value' => true,
'selected' => true,
'data-*' => true
);
$allowed_tags['optgroup'] = array(
'type' => true,
'style' => true,
'class' => true,
'id' => true,
'checked' => true,
'disabled' => true,
'name' => true,
'size' => true,
'placeholder' => true,
'value' => true,
'selected' => true,
'data-*' => true,
'label' => true
);
$allowed_tags['a'] = array(
'href' => true,
'data-*' => true,
'class' => true,
'style' => true,
'id' => true,
'target' => true,
'data-*' => true,
'role' => true,
'aria-controls' => true,
'aria-selected' => true,
'disabled' => true
);
$allowed_tags['div'] = array(
'style' => true,
'class' => true,
'id' => true,
'data-*' => true,
'role' => true,
'aria-labelledby' => true,
'value' => true,
'aria-modal' => true,
'tabindex' => true
);
$allowed_tags['li'] = array(
'style' => true,
'class' => true,
'id' => true,
'data-*' => true,
'role' => true,
'aria-labelledby' => true,
'value' => true,
'aria-modal' => true,
'tabindex' => true
);
$allowed_tags['span'] = array(
'style' => true,
'class' => true,
'id' => true,
'data-*' => true,
'aria-hidden' => true
);
$allowed_tags['style'] = array(
'class' => true,
'id' => true,
'type' => true
);
$allowed_tags['fieldset'] = array(
'class' => true,
'id' => true,
'type' => true
);
$allowed_tags['link'] = array(
'class' => true,
'id' => true,
'type' => true,
'rel' => true,
'href' => true,
'media' => true
);
$allowed_tags['form'] = array(
'style' => true,
'class' => true,
'id' => true,
'method' => true,
'action' => true,
'data-*' => true
);
$allowed_tags['script'] = array(
'class' => true,
'id' => true,
'type' => true,
'src' => true
);
echo wp_kses($html, $allowed_tags);
add_filter('safe_style_css', function ($styles) {
$styles_wf = array(
'text-align',
'margin',
'color',
'float',
'border',
'background',
'background-color',
'border-bottom',
'border-bottom-color',
'border-bottom-style',
'border-bottom-width',
'border-collapse',
'border-color',
'border-left',
'border-left-color',
'border-left-style',
'border-left-width',
'border-right',
'border-right-color',
'border-right-style',
'border-right-width',
'border-spacing',
'border-style',
'border-top',
'border-top-color',
'border-top-style',
'border-top-width',
'border-width',
'caption-side',
'clear',
'cursor',
'direction',
'font',
'font-family',
'font-size',
'font-style',
'font-variant',
'font-weight',
'height',
'letter-spacing',
'line-height',
'margin-bottom',
'margin-left',
'margin-right',
'margin-top',
'overflow',
'padding',
'padding-bottom',
'padding-left',
'padding-right',
'padding-top',
'text-decoration',
'text-indent',
'vertical-align',
'width'
);
foreach ($styles_wf as $style_wf) {
if (($key = array_search($style_wf, $styles)) !== false) {
unset($styles[$key]);
}
}
return $styles;
});
}
/**
* === HOOKS AND ACTIONS AND FILTERS AND SUCH ==========================================================
*/
$plugin = plugin_basename(__FILE__);
register_activation_hook( __FILE__, 'sticky_anything_activate' );
register_deactivation_hook( __FILE__, 'sticky_anything_deactivate' );
add_action('init','sticky_anything_update',1);
add_action('wp_enqueue_scripts', 'load_sticky_anything');
add_action('admin_menu', 'sticky_anything_menu');
add_action('admin_init', 'sticky_anything_admin_init');
add_action('admin_footer', 'sticky_anything_admin_footer');
add_action('admin_enqueue_scripts', 'sticky_anything_styles' );
add_filter("plugin_action_links_$plugin", 'sticky_anything_settings_link' );
add_filter('plugin_row_meta', 'sticky_plugin_meta_links', 10, 2);
add_filter('admin_footer_text', 'sticky_admin_footer_text');
add_action('admin_action_sticky_hide_review_notification', 'sticky_hide_review_notification');
add_action('wp_ajax_sticky_dismiss_notice', 'sticky_ajax_dismiss_notice');