File manager - Edit - /home/aresglob/public_html/wp/wp-includes/images/smilies/main.zip
Back
PK !fh[�_�0 0 download_google_fonts.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // download_google_fonts.php //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } // Download google fonts function pagelayer_pro_download_google_fonts($url){ global $wp_filesystem; if (!defined('FS_METHOD')) { define( 'FS_METHOD', 'direct' ); } $uploads_dir = wp_upload_dir(); $font_url = $uploads_dir['baseurl'].'/pl-google-fonts'; $font_dir = $uploads_dir['basedir'].'/pl-google-fonts'; // Find hash of current url $url_md5 = md5($url); $local_path = $font_dir.'/'.$url_md5.'.css'; if(file_exists( $local_path ) ){ return $local_path; } // Load Wp filesystem class if ( ! function_exists( 'WP_Filesystem' ) ) { $file_path = ABSPATH . 'site-admin/includes/file.php'; $file_path = file_exists($file_path) ? $file_path : ABSPATH . 'wp-admin/includes/file.php'; include $file_path; } WP_Filesystem(); // Is google fonts directory exists? if( !file_exists( $font_dir ) ){ wp_mkdir_p( $font_dir ); } //verify fonts upload directory exists or not $fonts_dir = $font_dir.'/fonts'; if( !file_exists( $fonts_dir ) ){ wp_mkdir_p($fonts_dir); } // Fetch stylesheet $useragent = array( 'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'); $response = wp_remote_get($url, $useragent); $response_code = wp_remote_retrieve_response_code($response); if ( is_wp_error( $response ) || $response_code !== 200 ) { return false; } $remote_file = wp_remote_retrieve_body($response); // Collect google fonts urls preg_match_all( '/url\(.*?\)/i', $remote_file, $font_links ); if(!isset( $font_links[0] ) || count( $font_links[0] ) < 1 ) { return false; } foreach( $font_links[0] as $key => $_fontlink ){ $download_url = str_ireplace( array('url(',')'), '', $_fontlink ); if(empty($download_url)){ continue; } $parse_url = parse_url($download_url); $font_name = basename($parse_url['path']); $local_file = $font_dir.'/fonts/'.$font_name; $_local_file = './fonts/'.$font_name; if( empty( $font_name ) || strpos($font_name, '.woff2') === false ){ continue; } // Download font files if(!file_exists( $local_file ) ){ $tmp_file = download_url( $download_url ); if(is_wp_error( $tmp_file )){ continue; } $wp_filesystem->copy( $tmp_file, $local_file ); $wp_filesystem->delete( $tmp_file ); } // Update font links $remote_file = str_replace( $download_url, $_local_file, $remote_file ); } // Save local stylesheet $wp_filesystem->put_contents( $local_path, $remote_file ); return $local_path; }PK !fh[|27��1 �1 functions.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // functions.php //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } // Is called when the ADMIN enables the plugin function pagelayer_pro_activation(){ global $wpdb; $sql = array(); add_option('pagelayer_pro_version', PAGELAYER_PRO_VERSION); add_option('pagelayer_pro_options', array()); // Update free verion pagelayer_pro_update_free_after_pro(null, array( 'action' => 'update', 'type' => 'plugin', 'plugin' => 'pagelayer-pro/pagelayer-pro.php', 'silent_skin' => true, )); } // Checks if we are to update ? function pagelayer_pro_update_check(){ global $wpdb; $sql = array(); $current_version = get_option('pagelayer_pro_version'); $version = (int) str_replace('.', '', $current_version); // No update required if($current_version == PAGELAYER_PRO_VERSION){ return true; } // Is it first run ? if(empty($current_version)){ // Reinstall pagelayer_pro_activation(); // Trick the following if conditions to not run $version = (int) str_replace('.', '', PAGELAYER_PRO_VERSION); } $is_network_wide = pagelayer_pro_is_network_active('pagelayer-pro'); if($is_network_wide){ $free_ins = get_site_option('pagelayer_free_installed'); }else{ $free_ins = get_option('pagelayer_free_installed'); } // If plugin runing reached here it means Pagelayer free installed if(empty($free_ins)){ if($is_network_wide){ update_site_option('pagelayer_free_installed', time()); }else{ update_option('pagelayer_free_installed', time()); } } // Re-init NAG dismiss expire time update_option('pagelayer_pro_older_pro_version_nag', time()); update_option('pagelayer_pro_older_free_version_nag', time()); // Save the new Version update_option('pagelayer_pro_version', PAGELAYER_PRO_VERSION); } // Load license data function pagelayer_pro_load_license($parent = 0){ global $pagelayer, $lic_resp; $license_field = 'pagelayer_license'; $license_api_url = PAGELAYER_PRO_API; // Save license if(!empty($parent) && is_string($parent) && strlen($parent) > 5){ $lic['license'] = $parent; // Load license of Soft Pro }elseif(!empty($parent)){ $license_field = 'softaculous_pro_license'; $lic = get_option('softaculous_pro_license', []); // My license }else{ $lic = get_option($license_field, []); } // Loaded license is a Soft Pro if(!empty($lic['license']) && preg_match('/^softwp/is', $lic['license'])){ $license_field = 'softaculous_pro_license'; $license_api_url = 'https://a.softaculous.com/softwp/'; $prods = apply_filters('softaculous_pro_products', []); }else{ $prods = []; } if(empty($lic['last_update'])){ $lic['last_update'] = time() - 86600; } // Update license details as well if(!empty($lic) && !empty($lic['license']) && (time() - @$lic['last_update']) >= 86400){ $url = $license_api_url.'/license.php?license='.$lic['license'].'&prods='.implode(',', $prods).'&url='.rawurlencode(site_url()); $resp = wp_remote_get($url); $lic_resp = $resp; //Did we get a response ? if(is_array($resp)){ $tosave = json_decode($resp['body'], true); //Is it the license ? if(!empty($tosave['license'])){ $tosave['last_update'] = time(); update_option($license_field, $tosave); $lic = $tosave; } } } // If the license is Free or Expired check for Softaculous Pro license if(empty($lic) || empty($lic['active'])){ if(function_exists('softaculous_pro_load_license')){ $softaculous_license = softaculous_pro_load_license(); if(!empty($softaculous_license['license']) && (!empty($softaculous_license['active']) || empty($lic['license'])) ){ $lic = $softaculous_license; } }elseif(empty($parent)){ $lic = get_option('softaculous_pro_license', []); if(!empty($lic)){ return pagelayer_pro_load_license(1); } } } if(!empty($lic['license'])){ $pagelayer->license = $lic; } } add_filter('softaculous_pro_products', 'pagelayer_softaculous_pro_products', 10, 1); function pagelayer_softaculous_pro_products($r = []){ $r['pagelayer'] = 'pagelayer'; return $r; } // Add our license key if ANY function pagelayer_pro_updater_filter_args($queryArgs) { global $pagelayer; if ( !empty($pagelayer->license['license']) ) { $queryArgs['license'] = $pagelayer->license['license']; } $queryArgs['url'] = rawurlencode(site_url()); return $queryArgs; } // Handle the Check for update link and ask to install license key function pagelayer_pro_updater_check_link($final_link){ global $pagelayer; if(empty($pagelayer->license['license'])){ return '<a href="'.admin_url('admin.php?page=pagelayer_license').'">Install Pagelayer Pro License Key</a>'; } return $final_link; } function pagelayer_pro_is_network_active($pluign){ $is_network_wide = false; // Handling network site if(!is_multisite()){ return $is_network_wide; } $_tmp_plugins = get_site_option('active_sitewide_plugins'); if(!empty($_tmp_plugins) && preg_grep('/.*\/'.$pluign.'\.php$/', array_keys($_tmp_plugins))){ $is_network_wide = true; } return $is_network_wide; } // Prevent update of pagelayer free function pagelayer_pro_get_free_version_num(){ if(defined('PAGELAYER_VERSION')){ return PAGELAYER_VERSION; } // In case of pagelayer deactive return pagelayer_pro_file_get_version_num('pagelayer/pagelayer.php'); } // Prevent update of pagelayer free function pagelayer_pro_file_get_version_num($plugin){ $file = WP_PLUGIN_DIR . '/'.$plugin; if(!file_exists($file)){ return false; } // In case of pagelayer deactive include_once(ABSPATH . 'wp-admin/includes/plugin.php'); $plugin_data = get_plugin_data($file); if(empty($plugin_data)){ return false; } return $plugin_data['Version']; } // Prevent update of pagelayer free function pagelayer_pro_disable_manual_update_for_plugin($transient){ $plugin = 'pagelayer/pagelayer.php'; // Is update available? if(!isset($transient->response) || !isset($transient->response[$plugin])){ return $transient; } $free_version = pagelayer_pro_get_free_version_num(); $pro_version = PAGELAYER_PRO_VERSION; if(!empty($GLOBALS['pagelayer_pro_is_upgraded'])){ $pro_version = pagelayer_pro_file_get_version_num('pagelayer-pro/pagelayer-pro.php'); } // Update the Pagelayer version to the equivalent of Pro version if(!empty($pro_version) && version_compare($free_version, $pro_version, '<')){ $transient->response[$plugin]->new_version = $pro_version; $transient->response[$plugin]->package = 'https://downloads.wordpress.org/plugin/pagelayer.'.$pro_version.'.zip'; }else{ unset($transient->response[$plugin]); } return $transient; } // Auto update free version after update pro version function pagelayer_pro_update_free_after_pro($upgrader_object, $options){ // Check if the action is an update for the plugins if($options['action'] != 'update' || $options['type'] != 'plugin'){ return; } // Define the slugs for the free and pro plugins $free_slug = 'pagelayer/pagelayer.php'; $pro_slug = 'pagelayer-pro/pagelayer-pro.php'; // Check if the pro plugin is in the list of updated plugins if( (isset($options['plugins']) && in_array($pro_slug, $options['plugins']) && !in_array($free_slug, $options['plugins'])) || (isset($options['plugin']) && $pro_slug == $options['plugin']) ){ // Trigger the update for the free plugin $current_version = pagelayer_pro_get_free_version_num(); if(empty($current_version)){ return; } $GLOBALS['pagelayer_pro_is_upgraded'] = true; // This will set the 'update_plugins' transient again wp_update_plugins(); // Check for updates for the free plugin $update_plugins = get_site_transient('update_plugins'); if(empty($update_plugins) || !isset($update_plugins->response[$free_slug]) || version_compare($update_plugins->response[$free_slug]->new_version, $current_version, '<=')){ return; } include_once(ABSPATH . 'wp-admin/includes/file.php'); include_once(ABSPATH . 'wp-admin/includes/misc.php'); require_once(ABSPATH . 'wp-admin/includes/plugin.php'); require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); $skin = wp_doing_ajax()? new WP_Ajax_Upgrader_Skin() : null; if(!empty($options['silent_skin'])){ class Pagelayer_Silent_Upgrader_Skin extends WP_Upgrader_Skin { public function feedback($string, ...$args){} public function header(){} public function footer(){} public function error($errors){} public function before(){} public function after(){} } $skin = new Pagelayer_Silent_Upgrader_Skin(); } $upgrader = new Plugin_Upgrader($skin); $upgraded = $upgrader->upgrade($free_slug); if(!is_wp_error($upgraded) && $upgraded){ // Re-active free plugins if( file_exists( WP_PLUGIN_DIR . '/'. $free_slug ) && is_plugin_inactive($free_slug) ){ activate_plugin($free_slug); // TODO for network } // Re-active pro plugins if( file_exists( WP_PLUGIN_DIR . '/'. $pro_slug ) && is_plugin_inactive($pro_slug) ){ activate_plugin($pro_slug); // TODO for network } } } } function pagelayer_pro_api_url($main_server = 0, $suffix = 'pagelayer'){ global $pagelayer; $r = array( 'https://s0.softaculous.com/a/softwp/', 'https://s1.softaculous.com/a/softwp/', 'https://s2.softaculous.com/a/softwp/', 'https://s3.softaculous.com/a/softwp/', 'https://s4.softaculous.com/a/softwp/', 'https://s5.softaculous.com/a/softwp/', 'https://s7.softaculous.com/a/softwp/', 'https://s8.softaculous.com/a/softwp/' ); $mirror = $r[array_rand($r)]; // If the license is newly issued, we need to fetch from API only if(!empty($main_server) || empty($pagelayer->license['last_edit']) || (!empty($pagelayer->license['last_edit']) && (time() - 3600) < $pagelayer->license['last_edit']) ){ $mirror = PAGELAYER_PRO_API; } if(!empty($suffix)){ $mirror = str_replace('/softwp', '/'.$suffix, $mirror); } return $mirror; } function pagelayer_pro_plugins_expired($plugins){ $plugins[] = 'Pagelayer'; return $plugins; } function pagelayer_pro_expiry_notice(){ global $pagelayer; // The combined notice for all Softaculous plugin to show that the license has expired $dismissed_at = get_option('softaculous_expired_licenses', 0); $expired_plugins = apply_filters('softaculous_expired_licenses', []); if( !empty($expired_plugins) && is_array($expired_plugins) && !defined('SOFTACULOUS_EXPIRY_LICENSES') && (empty($dismissed_at) || ($dismissed_at + WEEK_IN_SECONDS) < time()) ){ define('SOFTACULOUS_EXPIRY_LICENSES', true); // To make sure other plugins don't return a Notice echo '<div class="notice notice-error is-dismissible" id="pagelayer-pro-expiry-notice"> <p>'.sprintf(__('Your SoftWP license has %1$sexpired%2$s. Please renew it to continue receiving uninterrupted updates and support for %3$s.', 'pagelayer-pro'), '<font style="color:red;"><b>', '</b></font>', esc_html(implode(', ', $expired_plugins)) ). '</p> </div>'; wp_register_script('pagelayer-pro-expiry-notice', '', ['jquery'], PAGELAYER_PRO_VERSION, true); wp_enqueue_script('pagelayer-pro-expiry-notice'); wp_add_inline_script('pagelayer-pro-expiry-notice', ' jQuery(document).ready(function(){ jQuery("#pagelayer-pro-expiry-notice").on("click", ".notice-dismiss", function(e){ e.preventDefault(); let target = jQuery(e.target); let jEle = target.closest("#pagelayer-pro-expiry-notice"); jEle.slideUp(); jQuery.post("'.admin_url('admin-ajax.php').'", { security : "'.wp_create_nonce('pagelayer_expiry_notice').'", action: "pagelayer_pro_dismiss_expired_licenses", }, function(res){ if(!res["success"]){ alert(res["data"]); } }).fail(function(data){ alert("There seems to be some issue dismissing this alert"); }); }); })'); } }PK !fh[�Oy� pagelayer-init.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // pagelayer-init.php //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } // Ok so we are now ready to go register_activation_hook(PAGELAYER_PRO_FILE, 'pagelayer_pro_activation'); // Prevent update of pagelayer free // This also work for auto update add_filter('site_transient_update_plugins', 'pagelayer_pro_disable_manual_update_for_plugin'); add_filter('pre_site_transient_update_plugins', 'pagelayer_pro_disable_manual_update_for_plugin'); // Auto update free version after update pro version add_action('upgrader_process_complete', 'pagelayer_pro_update_free_after_pro', 10, 2); add_action('plugins_loaded', 'pagelayer_pro_load_plugin'); function pagelayer_pro_load_plugin(){ global $pagelayer; if(empty($pagelayer)){ $pagelayer = new stdClass(); } // Load license pagelayer_pro_load_license(); // Check if the installed version is outdated pagelayer_pro_update_check(); // Check for updates include_once(PAGELAYER_PRO_DIR.'/main/plugin-update-checker.php'); $pagelayer_updater = Pagelayer_PucFactory::buildUpdateChecker(pagelayer_pro_api_url().'updates.php?version='.PAGELAYER_PRO_VERSION, PAGELAYER_PRO_FILE); // Add the license key to query arguments $pagelayer_updater->addQueryArgFilter('pagelayer_pro_updater_filter_args'); // Show the text to install the license key add_filter('puc_manual_final_check_link-pagelayer-pro', 'pagelayer_pro_updater_check_link', 10, 1); // Nag informing the user to install the free version. if(current_user_can('activate_plugins')){ add_action('admin_notices', 'pagelayer_pro_free_version_nag', 9); add_action('admin_menu', 'pagelayer_pro_add_menu', 9); } $is_network_wide = pagelayer_pro_is_network_active('pagelayer-pro'); $_pl_version = get_option('pagelayer_version'); $req_free_update = !empty($_pl_version) && version_compare($_pl_version, '1.8.7', '<'); if($is_network_wide){ $pl_free_installed = get_site_option('pagelayer_free_installed'); }else{ $pl_free_installed = get_option('pagelayer_free_installed'); } if(!empty($pl_free_installed)){ return; } // Include the necessary stuff include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); include_once(ABSPATH . 'wp-admin/includes/plugin.php'); include_once(ABSPATH . 'wp-admin/includes/file.php'); if( file_exists( WP_PLUGIN_DIR . '/pagelayer/pagelayer.php' ) && is_plugin_inactive( '/pagelayer/pagelayer.php' ) && empty($req_free_update) ) { if($is_network_wide){ update_site_option('pagelayer_free_installed', time()); }else{ update_option('pagelayer_free_installed', time()); } activate_plugin('/pagelayer/pagelayer.php', '', $is_network_wide); remove_action('admin_notices', 'pagelayer_pro_free_version_nag', 9); remove_action('admin_menu', 'pagelayer_pro_add_menu', 9); return; } // Includes necessary for Plugin_Upgrader and Plugin_Installer_Skin include_once(ABSPATH . 'wp-admin/includes/misc.php'); include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); // Filter to prevent the activate text add_filter('install_plugin_complete_actions', 'pagelayer_pro_prevent_activation_text', 10, 3); $upgrader = new Plugin_Upgrader(new WP_Ajax_Upgrader_Skin()); // Upgrade the plugin to the latest version of free already installed. if(!empty($req_free_update) && file_exists( WP_PLUGIN_DIR . '/pagelayer/pagelayer.php' )){ $installed = $upgrader->upgrade('pagelayer/pagelayer.php'); }else{ $installed = $upgrader->install('https://downloads.wordpress.org/plugin/pagelayer.zip'); } if(!is_wp_error($installed) && $installed){ if($is_network_wide){ update_site_option('pagelayer_free_installed', time()); }else{ update_option('pagelayer_free_installed', time()); } activate_plugin('pagelayer/pagelayer.php', '', $is_network_wide); remove_action('admin_notices', 'pagelayer_pro_free_version_nag', 9); remove_action('admin_menu', 'pagelayer_pro_add_menu', 9); //wp_safe_redirect(admin_url('/')); } } // Do not shows the activation text if function pagelayer_pro_prevent_activation_text($install_actions, $api, $plugin_file){ if($plugin_file == 'pagelayer/pagelayer.php'){ return array(); } return $install_actions; } function pagelayer_pro_free_version_nag(){ $pl_version = get_option('pagelayer_version'); $lower_version = __('You have not installed/activated the free version of Pagelayer. Pagelayer Pro depends on the free version, so you must install/activate it first in order to use Pagelayer Pro.'); $btn_text = __('Install / Activate Now'); if(!empty($pl_version) && version_compare($pl_version, '1.8.6', '<')){ $lower_version = __('You are using an older version of the free version of Pagelayer, please update Pagelayer to work without any issues'); $btn_text = __('Update Now'); } echo '<div class="notice notice-error"> <p style="font-size:16px;">'.esc_html($lower_version).' <a href="'.admin_url('plugin-install.php?s=pagelayer&tab=search').'" class="button button-primary">'.esc_html($btn_text).'</a></p> </div>'; } function pagelayer_pro_add_menu(){ add_menu_page('Pagelayer', 'Pagelayer Pro', 'activate_plugins', 'pagelayer-pro', 'pagelayer_pro_menu_page', PAGELAYER_PRO_URL.'/images/pagelayer-logo-19.png'); } function pagelayer_pro_menu_page(){ echo '<div style="color: #333;padding: 50px;text-align: center;"> <h1 style="font-size: 2em;margin-bottom: 10px;">Pagelayer Free version is not installed / outdated!</h> <p style=" font-size: 16px;margin-bottom: 20px; font-weight:400;">Pagelayer Pro depends on the free version of Pagelayer, so you need to install / update the free version first.</p> <a href="'.admin_url('plugin-install.php?s=pagelayer&tab=search').'" style="text-decoration: none;font-size:16px;">Install/Update Now</a> </div>'; }PK !fh[9x�Ac c license.phpnu �[��� <?php if(!defined('ABSPATH')) { die('HACKING ATTEMPT!'); } include_once BACKUPLY_DIR . '/main/settings.php'; // Handles submission of license function backuply_license(){ global $backuply, $lic_resp; check_admin_referer('backuply_license_form', 'backuply_license_nonce'); $license = sanitize_key(backuply_optpost('backuply_license')); if(empty($license)) { add_settings_error('backuply-notice', esc_attr( 'settings_updated' ), esc_html__('The license key was not submitted', 'backuply'), 'error'); return; } if(!function_exists('backuply_load_license')){ $lic_resp = wp_remote_get(BACKUPLY_API.'/license.php?license='.$license.'&url='.rawurlencode(esc_url_raw(site_url())), array('timeout' => 30, 'sslverify' => false)); }else{ backuply_load_license($license); } if(is_array($lic_resp)){ $json = json_decode($lic_resp['body'], true); }else{ add_settings_error('backuply-notice', esc_attr( 'settings_updated' ), esc_html__('The response was malformed', 'backuply').'<br>'.var_export($lic_resp, true), 'error'); return; } // Save the License if(empty($json['license'])){ add_settings_error('backuply-notice', esc_attr( 'settings_updated' ), esc_html__('The license key is invalid', 'backuply'), 'error'); return; } if(!function_exists('backuply_load_license')){ if(get_option('backuply_license')) { update_option('backuply_license', $json); } else{ add_option('backuply_license', $json); } $backuply['license'] = $json; } } function backuply_license_page() { global $backuply; if(!empty($_POST['save_backuply_license'])) { backuply_license(); } // Update Cloud key and URL if(!empty($_POST['save_backuply_cloud_key'])){ backuply_cloud_update(); } backuply_page_header('License'); settings_errors('backuply-notice'); ?> <table class="wp-list-table fixed striped users backuply-license-table" cellspacing="1" border="0" width="95%" cellpadding="10" align="center"> <tbody> <tr> <th align="left" width="25%">Backuply Version</th> <td><?php echo BACKUPLY_VERSION.(defined('BACKUPLY_PRO') ? ' (Pro Version)' : ''); ?> </td> </tr> <tr> <th align="left" valign="top">Backuply License</th> <td align="left"> <form method="post"> <span style="color:red"><?php echo (defined('BACKUPLY_PRO') && empty($backuply['license']) ? '<span style="color:red">Unlicensed</span> ' : '')?></span> <input type="text" name="backuply_license" value="<?php echo (empty($backuply['license']) || empty($backuply['license']['license']) ? '' : esc_html($backuply['license']['license']))?>" size="30" placeholder="e.g. BAKLY-11111-22222-33333-44444" style="width:300px;"> <?php wp_nonce_field( 'backuply_license_form','backuply_license_nonce' ); ?> <input name="save_backuply_license" class="button button-primary" value="Update License" type="submit"> </form> <?php if(!empty($backuply['license']) && !empty($backuply['license']['expires'])){ $expires = $backuply['license']['expires']; $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6); echo '<div style="margin-top:10px;">License Status : '.(empty($backuply['license']['status_txt']) ? 'N.A.' : wp_kses_post($backuply['license']['status_txt'])).' '; if(empty($backuply['license']['has_plid']) || $backuply['license']['expires'] <= date('Ymd')){ echo 'License Expires : '.($backuply['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.esc_html($expires).'</span>' : esc_html($expires)); } echo '</div>'; } if(!empty($backuply['license']['quota']) && !empty($backuply['license']['quota'])){ echo '<div style="margin-top:3px;">Cloud Storage: '.size_format(esc_html($backuply['license']['quota'])).'</div>'; } ?> </td> </tr> <tr> <th align="left" valign="top">Backuply Cloud</th> <?php echo '<td align="left"> <div style="display:flex; flex-direction:column;"> <form method="post"> <label> <input type="text" name="bcloud_key" value="'.(!empty($backuply['bcloud_key']) ? esc_attr($backuply['bcloud_key']) : '').'" size="30" placeholder="Your Backuply Cloud Key" style="width:300px;"> '.wp_nonce_field('backuply_cloud_form', 'backuply_cloud_nonce').' <input name="save_backuply_cloud_key" class="button button-primary" value="Update Cloud Key" type="submit"> <p class="description">'.__('Backuply Cloud Key works in combination with Backuply License which you get when you buy a plan', 'backuply').'<br>'.__('The key is generated automatically, when you add Backuply Cloud location to a new site, for more info read this', 'backuply').' <a href="https://backuply.com/docs/backuply-cloud/how-to-get-backuply-cloud-key/#lost-backuply-clou-key" target="_blank">docs</a></p> </label> </form> <label> <input type="text" value="'.site_url().'" size="30" placeholder="Backuply Cloud Linked Site URL" style="width:300px;" readonly> <p class="description">Site URL</p> </label> </div> </td>'; ?> </tr> <tr> <th align="left">URL</th> <td><?php echo esc_url(get_site_url()); ?></td> </tr> <tr> <th align="left">Path</th> <td><?php echo ABSPATH; ?></td> </tr> <tr> <th align="left">Server's IP Address</th> <td><?php echo !empty($_SERVER['SERVER_ADDR']) ? wp_kses_post(wp_unslash($_SERVER['SERVER_ADDR'])) : '-'; ?></td> </tr> <tr> <th align="left">.htaccess is writable</th> <td><?php echo (is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>');?></td> </tr> </tbody> </table> </td> <td> <?php backuply_promotion_tmpl(); ?> </td> </tr> </table> </div> </div> </div> </div> <?php } function backuply_cloud_update(){ global $backuply; if(!wp_verify_nonce($_POST['backuply_cloud_nonce'], 'backuply_cloud_form')){ echo 'Security Check Failed'; return false; } $backuply['bcloud_key'] = sanitize_text_field($_POST['bcloud_key']); update_option('bcloud_key', $backuply['bcloud_key']); } PK !fh[���L� L� plugin-update-checker.phpnu �[��� <?php /** * Plugin Update Checker Library 3.2 * http://w-shadow.com/ * * Copyright 2016 Janis Elsts * Released under the MIT license. See license.txt for details. */ if ( !class_exists('SiteSEOUpdateChecker_3_2', false) ): /** * A custom plugin update checker. * * @author Janis Elsts * @copyright 2016 * @version 3.2 * @access public */ #[\AllowDynamicProperties] class SiteSEOUpdateChecker_3_2 { public $metadataUrl = ''; //The URL of the plugin's metadata file. public $pluginAbsolutePath = ''; //Full path of the main plugin file. public $pluginFile = ''; //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins. public $slug = ''; //Plugin slug. public $optionName = ''; //Where to store the update info. public $muPluginFile = ''; //For MU plugins, the plugin filename relative to the mu-plugins directory. public $debugMode = false; //Set to TRUE to enable error reporting. Errors are raised using trigger_error() //and should be logged to the standard PHP error log. public $scheduler; protected $upgraderStatus; private $debugBarPlugin = null; private $cachedInstalledVersion = null; private $metadataHost = ''; //The host component of $metadataUrl. /** * Class constructor. * * @param string $metadataUrl The URL of the plugin's metadata file. * @param string $pluginFile Fully qualified path to the main plugin file. * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug. * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks. * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'. * @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory. */ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = ''){ $this->metadataUrl = $metadataUrl; $this->pluginAbsolutePath = $pluginFile; $this->pluginFile = plugin_basename($this->pluginAbsolutePath); $this->muPluginFile = $muPluginFile; $this->slug = $slug; $this->optionName = $optionName; $this->debugMode = (bool)(constant('WP_DEBUG')); //If no slug is specified, use the name of the main plugin file as the slug. //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. if ( empty($this->slug) ){ $this->slug = basename($this->pluginFile, '.php'); } //Plugin slugs must be unique. $slugCheckFilter = 'puc_is_slug_in_use-' . $this->slug; $slugUsedBy = apply_filters($slugCheckFilter, false); if ( $slugUsedBy ) { $this->triggerError(sprintf( 'Plugin slug "%s" is already in use by %s. Slugs must be unique.', htmlentities($this->slug), htmlentities($slugUsedBy) ), E_USER_ERROR); } add_filter($slugCheckFilter, array($this, 'getAbsolutePath')); if ( empty($this->optionName) ){ $this->optionName = 'external_updates-' . $this->slug; } //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir). if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) { $this->muPluginFile = $this->pluginFile; } $this->scheduler = $this->createScheduler($checkPeriod); $this->upgraderStatus = new SiteSEO_PucUpgraderStatus_3_2(); $this->installHooks(); } /** * Create an instance of the scheduler. * * This is implemented as a method to make it possible for plugins to subclass the update checker * and substitute their own scheduler. * * @param int $checkPeriod * @return SiteSEO_PucScheduler_3_2 */ protected function createScheduler($checkPeriod) { return new SiteSEO_PucScheduler_3_2($this, $checkPeriod); } /** * Install the hooks required to run periodic update checks and inject update info * into WP data structures. * * @return void */ protected function installHooks(){ //Override requests for plugin information add_filter('plugins_api', array($this, 'injectInfo'), 20, 3); //Insert our update info into the update array maintained by WP. add_filter('site_transient_update_plugins', array($this,'injectUpdate')); //WP 3.0+ add_filter('transient_update_plugins', array($this,'injectUpdate')); //WP 2.8+ add_filter('site_transient_update_plugins', array($this, 'injectTranslationUpdates')); add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2); add_action('admin_init', array($this, 'handleManualCheck')); add_action('all_admin_notices', array($this, 'displayManualCheckResult')); //Clear the version number cache when something - anything - is upgraded or WP clears the update cache. add_filter('upgrader_post_install', array($this, 'clearCachedVersion')); add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion')); //Clear translation updates when WP clears the update cache. //This needs to be done directly because the library doesn't actually remove obsolete plugin updates, //it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O. add_action('delete_site_transient_update_plugins', array($this, 'clearCachedTranslationUpdates')); if ( did_action('plugins_loaded') ) { $this->initDebugBarPanel(); } else { add_action('plugins_loaded', array($this, 'initDebugBarPanel')); } //Rename the update directory to be the same as the existing directory. add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3); //Enable language support (i18n). load_plugin_textdomain('plugin-update-checker', false, plugin_basename(dirname(__FILE__)) . '/languages'); //Allow HTTP requests to the metadata URL even if it's on a local host. $this->metadataHost = @parse_url($this->metadataUrl, PHP_URL_HOST); add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2); } /** * Explicitly allow HTTP requests to the metadata URL. * * WordPress has a security feature where the HTTP API will reject all requests that are sent to * another site hosted on the same server as the current site (IP match), a local host, or a local * IP, unless the host exactly matches the current site. * * This feature is opt-in (at least in WP 4.4). Apparently some people enable it. * * That can be a problem when you're developing your plugin and you decide to host the update information * on the same server as your test site. Update requests will mysteriously fail. * * We fix that by adding an exception for the metadata host. * * @param bool $allow * @param string $host * @return bool */ public function allowMetadataHost($allow, $host) { if ( strtolower($host) === strtolower($this->metadataHost) ) { return true; } return $allow; } /** * Retrieve plugin info from the configured API endpoint. * * @uses wp_remote_get() * * @param array $queryArgs Additional query arguments to append to the request. Optional. * @return SiteSEOInfo_3_2 */ public function requestInfo($queryArgs = array()){ //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()). $installedVersion = $this->getInstalledVersion(); $queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : ''; $queryArgs = apply_filters('puc_request_info_query_args-'.$this->slug, $queryArgs); //Various options for the wp_remote_get() call. Plugins can filter these, too. $options = array( 'timeout' => 10, //seconds 'headers' => array( 'Accept' => 'application/json' ), ); $options = apply_filters('puc_request_info_options-'.$this->slug, $options); //The plugin info should be at 'http://your-api.com/url/here/$slug/info.json' $url = $this->metadataUrl; if ( !empty($queryArgs) ){ $url = add_query_arg($queryArgs, $url); } $result = wp_remote_get( $url, $options ); //Try to parse the response $status = $this->validateApiResponse($result); $pluginInfo = null; if ( !is_wp_error($status) ){ $pluginInfo = SiteSEOInfo_3_2::fromJson($result['body']); if ( $pluginInfo !== null ) { $pluginInfo->filename = $this->pluginFile; $pluginInfo->slug = $this->slug; } } else { $this->triggerError( sprintf('The URL %s does not point to a valid plugin metadata file. ', $url) . $status->get_error_message(), E_USER_WARNING ); } $pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result); return $pluginInfo; } /** * Check if $result is a successful update API response. * * @param array|WP_Error $result * @return true|WP_Error */ private function validateApiResponse($result) { if ( is_wp_error($result) ) { /** @var WP_Error $result */ return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message()); } if ( !isset($result['response']['code']) ) { return new WP_Error('puc_no_response_code', 'wp_remote_get() returned an unexpected result.'); } if ( $result['response']['code'] !== 200 ) { return new WP_Error( 'puc_unexpected_response_code', 'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)' ); } if ( empty($result['body']) ) { return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.'); } return true; } /** * Retrieve the latest update (if any) from the configured API endpoint. * * @uses SiteSEOUpdateChecker::requestInfo() * * @return SiteSEOUpdate_3_2 An instance of SiteSEOUpdate, or NULL when no updates are available. */ public function requestUpdate(){ //For the sake of simplicity, this function just calls requestInfo() //and transforms the result accordingly. $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1')); if ( $pluginInfo == null ){ return null; } $update = SiteSEOUpdate_3_2::fromSiteSEOInfo($pluginInfo); //Keep only those translation updates that apply to this site. $update->translations = $this->filterApplicableTranslations($update->translations); return $update; } /** * Filter a list of translation updates and return a new list that contains only updates * that apply to the current site. * * @param array $translations * @return array */ private function filterApplicableTranslations($translations) { $languages = array_flip(array_values(get_available_languages())); $installedTranslations = wp_get_installed_translations('plugins'); if ( isset($installedTranslations[$this->slug]) ) { $installedTranslations = $installedTranslations[$this->slug]; } else { $installedTranslations = array(); } $applicableTranslations = array(); foreach($translations as $translation) { //Does it match one of the available core languages? $isApplicable = array_key_exists($translation->language, $languages); //Is it more recent than an already-installed translation? if ( isset($installedTranslations[$translation->language]) ) { $updateTimestamp = strtotime($translation->updated); $installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']); $isApplicable = $updateTimestamp > $installedTimestamp; } if ( $isApplicable ) { $applicableTranslations[] = $translation; } } return $applicableTranslations; } /** * Get the currently installed version of the plugin. * * @return string Version number. */ public function getInstalledVersion(){ if ( isset($this->cachedInstalledVersion) ) { return $this->cachedInstalledVersion; } $pluginHeader = $this->getPluginHeader(); if ( isset($pluginHeader['Version']) ) { $this->cachedInstalledVersion = $pluginHeader['Version']; return $pluginHeader['Version']; } else { //This can happen if the filename points to something that is not a plugin. $this->triggerError( sprintf( "Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.", $this->pluginFile ), E_USER_WARNING ); return null; } } /** * Get plugin's metadata from its file header. * * @return array */ protected function getPluginHeader() { if ( !is_file($this->pluginAbsolutePath) ) { //This can happen if the plugin filename is wrong. $this->triggerError( sprintf( "Can't to read the plugin header for '%s'. The file does not exist.", $this->pluginFile ), E_USER_WARNING ); return array(); } if ( !function_exists('get_plugin_data') ){ /** @noinspection PhpIncludeInspection */ require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } return get_plugin_data($this->pluginAbsolutePath, false, false); } /** * Check for plugin updates. * The results are stored in the DB option specified in $optionName. * * @return SiteSEOUpdate_3_2|null */ public function checkForUpdates(){ $installedVersion = $this->getInstalledVersion(); //Fail silently if we can't find the plugin or read its header. if ( $installedVersion === null ) { $this->triggerError( sprintf('Skipping update check for %s - installed version unknown.', $this->pluginFile), E_USER_WARNING ); return null; } $state = $this->getUpdateState(); if ( empty($state) ){ $state = new stdClass; $state->lastCheck = 0; $state->checkedVersion = ''; $state->update = null; } $state->lastCheck = time(); $state->checkedVersion = $installedVersion; $this->setUpdateState($state); //Save before checking in case something goes wrong $state->update = $this->requestUpdate(); $this->setUpdateState($state); return $this->getUpdate(); } /** * Load the update checker state from the DB. * * @return stdClass|null */ public function getUpdateState() { $state = get_site_option($this->optionName, null); if ( empty($state) || !is_object($state)) { $state = null; } if ( isset($state, $state->update) && is_object($state->update) ) { $state->update = SiteSEOUpdate_3_2::fromObject($state->update); } return $state; } /** * Persist the update checker state to the DB. * * @param StdClass $state * @return void */ private function setUpdateState($state) { if ( isset($state->update) && is_object($state->update) && method_exists($state->update, 'toStdClass') ) { $update = $state->update; /** @var SiteSEOUpdate_3_2 $update */ $state->update = $update->toStdClass(); } update_site_option($this->optionName, $state); } /** * Reset update checker state - i.e. last check time, cached update data and so on. * * Call this when your plugin is being uninstalled, or if you want to * clear the update cache. */ public function resetUpdateState() { delete_site_option($this->optionName); } /** * Intercept plugins_api() calls that request information about our plugin and * use the configured API endpoint to satisfy them. * * @see plugins_api() * * @param mixed $result * @param string $action * @param array|object $args * @return mixed */ public function injectInfo($result, $action = null, $args = null){ $relevant = ($action == 'plugin_information') && isset($args->slug) && ( ($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile)) ); if ( !$relevant ) { return $result; } $pluginInfo = $this->requestInfo(); $pluginInfo = apply_filters('puc_pre_inject_info-' . $this->slug, $pluginInfo); if ( $pluginInfo ) { return $pluginInfo->toWpFormat(); } return $result; } /** * Insert the latest update (if any) into the update list maintained by WP. * * @param StdClass $updates Update list. * @return StdClass Modified update list. */ public function injectUpdate($updates){ //Is there an update to insert? $update = $this->getUpdate(); //No update notifications for mu-plugins unless explicitly enabled. The MU plugin file //is usually different from the main plugin file so the update wouldn't show up properly anyway. if ( $this->isUnknownMuPlugin() ) { $update = null; } if ( !empty($update) ) { //Let plugins filter the update info before it's passed on to WordPress. $update = apply_filters('puc_pre_inject_update-' . $this->slug, $update); $updates = $this->addUpdateToList($updates, $update); } else { //Clean up any stale update info. $updates = $this->removeUpdateFromList($updates); } return $updates; } /** * @param StdClass|null $updates * @param SiteSEOUpdate_3_2 $updateToAdd * @return StdClass */ private function addUpdateToList($updates, $updateToAdd) { if ( !is_object($updates) ) { $updates = new stdClass(); $updates->response = array(); } $wpUpdate = $updateToAdd->toWpFormat(); $pluginFile = $this->pluginFile; if ( $this->isMuPlugin() ) { //WP does not support automatic update installation for mu-plugins, but we can still display a notice. $wpUpdate->package = null; $pluginFile = $this->muPluginFile; } $updates->response[$pluginFile] = $wpUpdate; return $updates; } /** * @param stdClass|null $updates * @return stdClass|null */ private function removeUpdateFromList($updates) { if ( isset($updates, $updates->response) ) { unset($updates->response[$this->pluginFile]); if ( !empty($this->muPluginFile) ) { unset($updates->response[$this->muPluginFile]); } } return $updates; } /** * Insert translation updates into the list maintained by WordPress. * * @param stdClass $updates * @return stdClass */ public function injectTranslationUpdates($updates) { $translationUpdates = $this->getTranslationUpdates(); if ( empty($translationUpdates) ) { return $updates; } //Being defensive. if ( !is_object($updates) ) { $updates = new stdClass(); } if ( !isset($updates->translations) ) { $updates->translations = array(); } //In case there's a name collision with a plugin hosted on wordpress.org, //remove any preexisting updates that match our plugin. $translationType = 'plugin'; $filteredTranslations = array(); foreach($updates->translations as $translation) { if ( ($translation['type'] === $translationType) && ($translation['slug'] === $this->slug) ) { continue; } $filteredTranslations[] = $translation; } $updates->translations = $filteredTranslations; //Add our updates to the list. foreach($translationUpdates as $update) { $convertedUpdate = array_merge( array( 'type' => $translationType, 'slug' => $this->slug, 'autoupdate' => 0, //AFAICT, WordPress doesn't actually use the "version" field for anything. //But lets make sure it's there, just in case. 'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)), ), (array)$update ); $updates->translations[] = $convertedUpdate; } return $updates; } /** * Rename the update directory to match the existing plugin directory. * * When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain * exactly one directory, and that the directory name will be the same as the directory where * the plugin/theme is currently installed. * * GitHub and other repositories provide ZIP downloads, but they often use directory names like * "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder. * * This is a hook callback. Don't call it from a plugin. * * @param string $source The directory to copy to /wp-content/plugins. Usually a subdirectory of $remoteSource. * @param string $remoteSource WordPress has extracted the update to this directory. * @param WP_Upgrader $upgrader * @return string|WP_Error */ public function fixDirectoryName($source, $remoteSource, $upgrader) { global $wp_filesystem; /** @var WP_Filesystem_Base $wp_filesystem */ //Basic sanity checks. if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) { return $source; } //If WordPress is upgrading anything other than our plugin, leave the directory name unchanged. if ( !$this->isPluginBeingUpgraded($upgrader) ) { return $source; } //Rename the source to match the existing plugin directory. $pluginDirectoryName = dirname($this->pluginFile); if ( $pluginDirectoryName === '.' ) { return $source; } $correctedSource = trailingslashit($remoteSource) . $pluginDirectoryName . '/'; if ( $source !== $correctedSource ) { //The update archive should contain a single directory that contains the rest of plugin files. Otherwise, //WordPress will try to copy the entire working directory ($source == $remoteSource). We can't rename //$remoteSource because that would break WordPress code that cleans up temporary files after update. if ( $this->isBadDirectoryStructure($remoteSource) ) { return new WP_Error( 'puc-incorrect-directory-structure', sprintf( 'The directory structure of the update is incorrect. All plugin files should be inside ' . 'a directory named <span class="code">%s</span>, not at the root of the ZIP file.', htmlentities($this->slug) ) ); } /** @var WP_Upgrader_Skin $upgrader->skin */ $upgrader->skin->feedback(sprintf( 'Renaming %s to %s…', '<span class="code">' . basename($source) . '</span>', '<span class="code">' . $pluginDirectoryName . '</span>' )); if ( $wp_filesystem->move($source, $correctedSource, true) ) { $upgrader->skin->feedback('Plugin directory successfully renamed.'); return $correctedSource; } else { return new WP_Error( 'puc-rename-failed', 'Unable to rename the update to match the existing plugin directory.' ); } } return $source; } /** * Check for incorrect update directory structure. An update must contain a single directory, * all other files should be inside that directory. * * @param string $remoteSource Directory path. * @return bool */ private function isBadDirectoryStructure($remoteSource) { global $wp_filesystem; /** @var WP_Filesystem_Base $wp_filesystem */ $sourceFiles = $wp_filesystem->dirlist($remoteSource); if ( is_array($sourceFiles) ) { $sourceFiles = array_keys($sourceFiles); $firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0]; return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath)); } //Assume it's fine. return false; } /** * Is there and update being installed RIGHT NOW, for this specific plugin? * * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update. * @return bool */ public function isPluginBeingUpgraded($upgrader = null) { return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader); } /** * Get the details of the currently available update, if any. * * If no updates are available, or if the last known update version is below or equal * to the currently installed version, this method will return NULL. * * Uses cached update data. To retrieve update information straight from * the metadata URL, call requestUpdate() instead. * * @return SiteSEOUpdate_3_2|null */ public function getUpdate() { $state = $this->getUpdateState(); /** @var StdClass $state */ //Is there an update available? if ( isset($state, $state->update) ) { $update = $state->update; //Check if the update is actually newer than the currently installed version. $installedVersion = $this->getInstalledVersion(); if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){ $update->filename = $this->pluginFile; return $update; } } return null; } /** * Get a list of available translation updates. * * This method will return an empty array if there are no updates. * Uses cached update data. * * @return array */ public function getTranslationUpdates() { $state = $this->getUpdateState(); if ( isset($state, $state->update, $state->update->translations) ) { return $state->update->translations; } return array(); } /** * Remove all cached translation updates. * * @see wp_clean_update_cache */ public function clearCachedTranslationUpdates() { $state = $this->getUpdateState(); if ( isset($state, $state->update, $state->update->translations) ) { $state->update->translations = array(); $this->setUpdateState($state); } } /** * Add a "Check for updates" link to the plugin row in the "Plugins" page. By default, * the new link will appear after the "Visit plugin site" link. * * You can change the link text by using the "puc_manual_check_link-$slug" filter. * Returning an empty string from the filter will disable the link. * * @param array $pluginMeta Array of meta links. * @param string $pluginFile * @return array */ public function addCheckForUpdatesLink($pluginMeta, $pluginFile) { $isRelevant = ($pluginFile == $this->pluginFile) || (!empty($this->muPluginFile) && $pluginFile == $this->muPluginFile); if ( $isRelevant && current_user_can('update_plugins') ) { $linkUrl = wp_nonce_url( add_query_arg( array( 'puc_check_for_updates' => 1, 'puc_slug' => $this->slug, ), self_admin_url('plugins.php') ), 'puc_check_for_updates' ); $linkText = apply_filters('puc_manual_check_link-' . $this->slug, __('Check for updates', 'siteseo-pro')); if ( !empty($linkText) ) { $final_link = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText); $pluginMeta[] = apply_filters('puc_manual_final_check_link-' . $this->slug, $final_link); } } return $pluginMeta; } /** * Check for updates when the user clicks the "Check for updates" link. * @see self::addCheckForUpdatesLink() * * @return void */ public function handleManualCheck() { $shouldCheck = isset($_GET['puc_check_for_updates'], $_GET['puc_slug']) && $_GET['puc_slug'] == $this->slug && current_user_can('update_plugins') && check_admin_referer('puc_check_for_updates'); if ( $shouldCheck ) { $update = $this->checkForUpdates(); $status = ($update === null) ? 'no_update' : 'update_available'; wp_redirect(add_query_arg( array( 'puc_update_check_result' => $status, 'puc_slug' => $this->slug, ), self_admin_url('plugins.php') )); } } /** * Display the results of a manual update check. * @see self::handleManualCheck() * * You can change the result message by using the "puc_manual_check_message-$slug" filter. */ public function displayManualCheckResult() { if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) { $status = strval($_GET['puc_update_check_result']); if ( $status == 'no_update' ) { $message = __('This plugin is up to date.', 'siteseo-pro'); } else if ( $status == 'update_available' ) { $message = __('A new version of this plugin is available.', 'siteseo-pro'); } else { // Translators: %s is the status of the update checker. $message = sprintf(__('Unknown update checker status "%s"', 'siteseo-pro'), htmlentities($status)); } printf( '<div class="updated notice is-dismissible"><p>%s</p></div>', apply_filters('puc_manual_check_message-' . $this->slug, $message, $status) ); } } /** * Check if the plugin file is inside the mu-plugins directory. * * @return bool */ protected function isMuPlugin() { static $cachedResult = null; if ( $cachedResult === null ) { //Convert both paths to the canonical form before comparison. $muPluginDir = realpath(WPMU_PLUGIN_DIR); $pluginPath = realpath($this->pluginAbsolutePath); if(!empty($muPluginDir)){ $cachedResult = (strpos($pluginPath, $muPluginDir) === 0); }else{ $cachedResult = false; } } return $cachedResult; } /** * MU plugins are partially supported, but only when we know which file in mu-plugins * corresponds to this plugin. * * @return bool */ protected function isUnknownMuPlugin() { return empty($this->muPluginFile) && $this->isMuPlugin(); } /** * Clear the cached plugin version. This method can be set up as a filter (hook) and will * return the filter argument unmodified. * * @param mixed $filterArgument * @return mixed */ public function clearCachedVersion($filterArgument = null) { $this->cachedInstalledVersion = null; return $filterArgument; } /** * Get absolute path to the main plugin file. * * @return string */ public function getAbsolutePath() { return $this->pluginAbsolutePath; } /** * Register a callback for filtering query arguments. * * The callback function should take one argument - an associative array of query arguments. * It should return a modified array of query arguments. * * @uses add_filter() This method is a convenience wrapper for add_filter(). * * @param callable $callback * @return void */ public function addQueryArgFilter($callback){ add_filter('puc_request_info_query_args-'.$this->slug, $callback); } /** * Register a callback for filtering arguments passed to wp_remote_get(). * * The callback function should take one argument - an associative array of arguments - * and return a modified array or arguments. See the WP documentation on wp_remote_get() * for details on what arguments are available and how they work. * * @uses add_filter() This method is a convenience wrapper for add_filter(). * * @param callable $callback * @return void */ public function addHttpRequestArgFilter($callback){ add_filter('puc_request_info_options-'.$this->slug, $callback); } /** * Register a callback for filtering the plugin info retrieved from the external API. * * The callback function should take two arguments. If the plugin info was retrieved * successfully, the first argument passed will be an instance of SiteSEOInfo. Otherwise, * it will be NULL. The second argument will be the corresponding return value of * wp_remote_get (see WP docs for details). * * The callback function should return a new or modified instance of SiteSEOInfo or NULL. * * @uses add_filter() This method is a convenience wrapper for add_filter(). * * @param callable $callback * @return void */ public function addResultFilter($callback){ add_filter('puc_request_info_result-'.$this->slug, $callback, 10, 2); } /** * Register a callback for one of the update checker filters. * * Identical to add_filter(), except it automatically adds the "puc_" prefix * and the "-$plugin_slug" suffix to the filter name. For example, "request_info_result" * becomes "puc_request_info_result-your_plugin_slug". * * @param string $tag * @param callable $callback * @param int $priority * @param int $acceptedArgs */ public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) { add_filter('puc_' . $tag . '-' . $this->slug, $callback, $priority, $acceptedArgs); } /** * Initialize the update checker Debug Bar plugin/add-on thingy. */ public function initDebugBarPanel() { $debugBarPlugin = dirname(__FILE__) . '/debug-bar-plugin.php'; if ( class_exists('Debug_Bar', false) && file_exists($debugBarPlugin) ) { /** @noinspection PhpIncludeInspection */ require_once $debugBarPlugin; $this->debugBarPlugin = new SiteSEO_PucDebugBarPlugin_3_2($this); } } /** * Trigger a PHP error, but only when $debugMode is enabled. * * @param string $message * @param int $errorType */ protected function triggerError($message, $errorType) { if ( $this->debugMode ) { trigger_error($message, $errorType); } } } endif; if ( !class_exists('SiteSEOInfo_3_2', false) ): /** * A container class for holding and transforming various plugin metadata. * * @author Janis Elsts * @copyright 2016 * @version 3.2 * @access public */ #[\AllowDynamicProperties] class SiteSEOInfo_3_2 { //Most fields map directly to the contents of the plugin's info.json file. //See the relevant docs for a description of their meaning. public $name; public $slug; public $version; public $homepage; public $sections = array(); public $banners; public $translations = array(); public $download_url; public $author; public $author_homepage; public $requires; public $tested; public $upgrade_notice; public $rating; public $num_ratings; public $downloaded; public $active_installs; public $last_updated; public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything. public $filename; //Plugin filename relative to the plugins directory. /** * Create a new instance of SiteSEOInfo from JSON-encoded plugin info * returned by an external update API. * * @param string $json Valid JSON string representing plugin info. * @return SiteSEOInfo_3_2|null New instance of SiteSEOInfo, or NULL on error. */ public static function fromJson($json){ /** @var StdClass $apiResponse */ $apiResponse = json_decode($json); if ( empty($apiResponse) || !is_object($apiResponse) ){ trigger_error( "Failed to parse plugin metadata. Try validating your .json file with http://jsonlint.com/", E_USER_NOTICE ); return null; } $valid = self::validateMetadata($apiResponse); if ( is_wp_error($valid) ){ trigger_error($valid->get_error_message(), E_USER_NOTICE); return null; } $info = new self(); foreach(get_object_vars($apiResponse) as $key => $value){ $info->$key = $value; } //json_decode decodes assoc. arrays as objects. We want it as an array. $info->sections = (array)$info->sections; return $info; } /** * Very, very basic validation. * * @param StdClass $apiResponse * @return bool|WP_Error */ protected static function validateMetadata($apiResponse) { if ( !isset($apiResponse->name, $apiResponse->version) || empty($apiResponse->name) || empty($apiResponse->version) ) { return new WP_Error( 'puc-invalid-metadata', "The plugin metadata file does not contain the required 'name' and/or 'version' keys." ); } return true; } /** * Transform plugin info into the format used by the native WordPress.org API * * @return object */ public function toWpFormat(){ $info = new stdClass; //The custom update API is built so that many fields have the same name and format //as those returned by the native WordPress.org API. These can be assigned directly. $sameFormat = array( 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice', 'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated', ); foreach($sameFormat as $field){ if ( isset($this->$field) ) { $info->$field = $this->$field; } else { $info->$field = null; } } //Other fields need to be renamed and/or transformed. $info->download_link = $this->download_url; $info->author = $this->getFormattedAuthor(); $info->sections = array_merge(array('description' => ''), $this->sections); if ( !empty($this->banners) ) { //WP expects an array with two keys: "high" and "low". Both are optional. //Docs: https://wordpress.org/plugins/about/faq/#banners $info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners; $info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true)); } return $info; } protected function getFormattedAuthor() { if ( !empty($this->author_homepage) ){ return sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author); } return $this->author; } } endif; if ( !class_exists('SiteSEOUpdate_3_2', false) ): /** * A simple container class for holding information about an available update. * * @author Janis Elsts * @copyright 2016 * @version 3.2 * @access public */ #[\AllowDynamicProperties] class SiteSEOUpdate_3_2 { public $id = 0; public $slug; public $version; public $homepage; public $download_url; public $upgrade_notice; public $tested; public $translations = array(); public $filename; //Plugin filename relative to the plugins directory. private static $fields = array( 'id', 'slug', 'version', 'homepage', 'tested', 'download_url', 'upgrade_notice', 'filename', 'translations' ); /** * Create a new instance of SiteSEOUpdate from its JSON-encoded representation. * * @param string $json * @return SiteSEOUpdate_3_2|null */ public static function fromJson($json){ //Since update-related information is simply a subset of the full plugin info, //we can parse the update JSON as if it was a plugin info string, then copy over //the parts that we care about. $pluginInfo = SiteSEOInfo_3_2::fromJson($json); if ( $pluginInfo != null ) { return self::fromSiteSEOInfo($pluginInfo); } else { return null; } } /** * Create a new instance of SiteSEOUpdate based on an instance of SiteSEOInfo. * Basically, this just copies a subset of fields from one object to another. * * @param SiteSEOInfo_3_2 $info * @return SiteSEOUpdate_3_2 */ public static function fromSiteSEOInfo($info){ return self::fromObject($info); } /** * Create a new instance of SiteSEOUpdate by copying the necessary fields from * another object. * * @param StdClass|SiteSEOInfo_3_2|SiteSEOUpdate_3_2 $object The source object. * @return SiteSEOUpdate_3_2 The new copy. */ public static function fromObject($object) { $update = new self(); $fields = self::$fields; if ( !empty($object->slug) ) { $fields = apply_filters('puc_retain_fields-' . $object->slug, $fields); } foreach($fields as $field){ if (property_exists($object, $field)) { $update->$field = $object->$field; } } return $update; } /** * Create an instance of StdClass that can later be converted back to * a SiteSEOUpdate. Useful for serialization and caching, as it avoids * the "incomplete object" problem if the cached value is loaded before * this class. * * @return StdClass */ public function toStdClass() { $object = new stdClass(); $fields = self::$fields; if ( !empty($this->slug) ) { $fields = apply_filters('puc_retain_fields-' . $this->slug, $fields); } foreach($fields as $field){ if (property_exists($this, $field)) { $object->$field = $this->$field; } } return $object; } /** * Transform the update into the format used by WordPress native plugin API. * * @return object */ public function toWpFormat(){ $update = new stdClass; $update->id = $this->id; $update->slug = $this->slug; $update->new_version = $this->version; $update->url = $this->homepage; $update->package = $this->download_url; $update->tested = $this->tested; $update->plugin = $this->filename; if ( !empty($this->upgrade_notice) ){ $update->upgrade_notice = $this->upgrade_notice; } return $update; } } endif; if ( !class_exists('SiteSEO_PucScheduler_3_2', false) ): /** * The scheduler decides when and how often to check for updates. * It calls @see SiteSEOUpdateChecker::checkForUpdates() to perform the actual checks. * * @version 3.2 */ class SiteSEO_PucScheduler_3_2 { public $checkPeriod = 12; //How often to check for updates (in hours). public $throttleRedundantChecks = false; //Check less often if we already know that an update is available. public $throttledCheckPeriod = 72; /** * @var SiteSEOUpdateChecker_3_2 */ protected $updateChecker; private $cronHook = null; /** * Scheduler constructor. * * @param SiteSEOUpdateChecker_3_2 $updateChecker * @param int $checkPeriod How often to check for updates (in hours). */ public function __construct($updateChecker, $checkPeriod) { $this->updateChecker = $updateChecker; $this->checkPeriod = $checkPeriod; //Set up the periodic update checks $this->cronHook = 'check_plugin_updates-' . $this->updateChecker->slug; if ( $this->checkPeriod > 0 ){ //Trigger the check via Cron. //Try to use one of the default schedules if possible as it's less likely to conflict //with other plugins and their custom schedules. $defaultSchedules = array( 1 => 'hourly', 12 => 'twicedaily', 24 => 'daily', ); if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) { $scheduleName = $defaultSchedules[$this->checkPeriod]; } else { //Use a custom cron schedule. $scheduleName = 'every' . $this->checkPeriod . 'hours'; add_filter('cron_schedules', array($this, '_addCustomSchedule')); } if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) { wp_schedule_event(time(), $scheduleName, $this->cronHook); } add_action($this->cronHook, array($this, 'maybeCheckForUpdates')); register_deactivation_hook($this->updateChecker->pluginFile, array($this, '_removeUpdaterCron')); //In case Cron is disabled or unreliable, we also manually trigger //the periodic checks while the user is browsing the Dashboard. add_action( 'admin_init', array($this, 'maybeCheckForUpdates') ); //Like WordPress itself, we check more often on certain pages. /** @see wp_update_plugins */ add_action('load-update-core.php', array($this, 'maybeCheckForUpdates')); add_action('load-plugins.php', array($this, 'maybeCheckForUpdates')); add_action('load-update.php', array($this, 'maybeCheckForUpdates')); //This hook fires after a bulk update is complete. add_action('upgrader_process_complete', array($this, 'maybeCheckForUpdates'), 11, 0); } else { //Periodic checks are disabled. wp_clear_scheduled_hook($this->cronHook); } } /** * Check for updates if the configured check interval has already elapsed. * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron. * * You can override the default behaviour by using the "puc_check_now-$slug" filter. * The filter callback will be passed three parameters: * - Current decision. TRUE = check updates now, FALSE = don't check now. * - Last check time as a Unix timestamp. * - Configured check period in hours. * Return TRUE to check for updates immediately, or FALSE to cancel. * * This method is declared public because it's a hook callback. Calling it directly is not recommended. */ public function maybeCheckForUpdates(){ if ( empty($this->checkPeriod) ){ return; } $state = $this->updateChecker->getUpdateState(); $shouldCheck = empty($state) || !isset($state->lastCheck) || ( (time() - $state->lastCheck) >= $this->getEffectiveCheckPeriod() ); //Let plugin authors substitute their own algorithm. $shouldCheck = apply_filters( 'puc_check_now-' . $this->updateChecker->slug, $shouldCheck, (!empty($state) && isset($state->lastCheck)) ? $state->lastCheck : 0, $this->checkPeriod ); if ( $shouldCheck ) { $this->updateChecker->checkForUpdates(); } } /** * Calculate the actual check period based on the current status and environment. * * @return int Check period in seconds. */ protected function getEffectiveCheckPeriod() { $currentFilter = current_filter(); if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) { //Check more often when the user visits "Dashboard -> Updates" or does a bulk update. $period = 60; } else if ( in_array($currentFilter, array('load-plugins.php', 'load-update.php')) ) { //Also check more often on the "Plugins" page and /wp-admin/update.php. $period = 3600; } else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) { //Check less frequently if it's already known that an update is available. $period = $this->throttledCheckPeriod * 3600; } else if ( defined('DOING_CRON') && constant('DOING_CRON') ) { //WordPress cron schedules are not exact, so lets do an update check even //if slightly less than $checkPeriod hours have elapsed since the last check. $cronFuzziness = 20 * 60; $period = $this->checkPeriod * 3600 - $cronFuzziness; } else { $period = $this->checkPeriod * 3600; } return $period; } /** * Add our custom schedule to the array of Cron schedules used by WP. * * @param array $schedules * @return array */ public function _addCustomSchedule($schedules){ if ( $this->checkPeriod && ($this->checkPeriod > 0) ){ $scheduleName = 'every' . $this->checkPeriod . 'hours'; $schedules[$scheduleName] = array( 'interval' => $this->checkPeriod * 3600, 'display' => sprintf('Every %d hours', $this->checkPeriod), ); } return $schedules; } /** * Remove the scheduled cron event that the library uses to check for updates. * * @return void */ public function _removeUpdaterCron(){ wp_clear_scheduled_hook($this->cronHook); } /** * Get the name of the update checker's WP-cron hook. Mostly useful for debugging. * * @return string */ public function getCronHookName() { return $this->cronHook; } } endif; if ( !class_exists('SiteSEO_PucUpgraderStatus_3_2', false) ): /** * A utility class that helps figure out which plugin WordPress is upgrading. * * It may seem strange to have an separate class just for that, but the task is surprisingly complicated. * Core classes like Plugin_Upgrader don't expose the plugin file name during an in-progress update (AFAICT). * This class uses a few workarounds and heuristics to get the file name. */ #[\AllowDynamicProperties] class SiteSEO_PucUpgraderStatus_3_2 { private $upgradedPluginFile = null; //The plugin that is currently being upgraded by WordPress. public function __construct() { //Keep track of which plugin WordPress is currently upgrading. add_filter('upgrader_pre_install', array($this, 'setUpgradedPlugin'), 10, 2); add_filter('upgrader_package_options', array($this, 'setUpgradedPluginFromOptions'), 10, 1); add_filter('upgrader_post_install', array($this, 'clearUpgradedPlugin'), 10, 1); add_action('upgrader_process_complete', array($this, 'clearUpgradedPlugin'), 10, 1); } /** * Is there and update being installed RIGHT NOW, for a specific plugin? * * Caution: This method is unreliable. WordPress doesn't make it easy to figure out what it is upgrading, * and upgrader implementations are liable to change without notice. * * @param string $pluginFile The plugin to check. * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update. * @return bool True if the plugin identified by $pluginFile is being upgraded. */ public function isPluginBeingUpgraded($pluginFile, $upgrader = null) { if ( isset($upgrader) ) { $upgradedPluginFile = $this->getPluginBeingUpgradedBy($upgrader); if ( !empty($upgradedPluginFile) ) { $this->upgradedPluginFile = $upgradedPluginFile; } } return ( !empty($this->upgradedPluginFile) && ($this->upgradedPluginFile === $pluginFile) ); } /** * Get the file name of the plugin that's currently being upgraded. * * @param Plugin_Upgrader|WP_Upgrader $upgrader * @return string|null */ private function getPluginBeingUpgradedBy($upgrader) { if ( !isset($upgrader, $upgrader->skin) ) { return null; } //Figure out which plugin is being upgraded. $pluginFile = null; $skin = $upgrader->skin; if ( $skin instanceof Plugin_Upgrader_Skin ) { if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) { $pluginFile = $skin->plugin; } } elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) { //This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin //filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can //do is compare those headers to the headers of installed plugins. $pluginFile = $this->identifyPluginByHeaders($skin->plugin_info); } return $pluginFile; } /** * Identify an installed plugin based on its headers. * * @param array $searchHeaders The plugin file header to look for. * @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin. */ private function identifyPluginByHeaders($searchHeaders) { if ( !function_exists('get_plugins') ){ /** @noinspection PhpIncludeInspection */ require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } $installedPlugins = get_plugins(); $matches = array(); foreach($installedPlugins as $pluginBasename => $headers) { $diff1 = array_diff_assoc($headers, $searchHeaders); $diff2 = array_diff_assoc($searchHeaders, $headers); if ( empty($diff1) && empty($diff2) ) { $matches[] = $pluginBasename; } } //It's possible (though very unlikely) that there could be two plugins with identical //headers. In that case, we can't unambiguously identify the plugin that's being upgraded. if ( count($matches) !== 1 ) { return null; } return reset($matches); } /** * @access private * * @param mixed $input * @param array $hookExtra * @return mixed Returns $input unaltered. */ public function setUpgradedPlugin($input, $hookExtra) { if (!empty($hookExtra['plugin']) && is_string($hookExtra['plugin'])) { $this->upgradedPluginFile = $hookExtra['plugin']; } else { $this->upgradedPluginFile = null; } return $input; } /** * @access private * * @param array $options * @return array */ public function setUpgradedPluginFromOptions($options) { if (isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin'])) { $this->upgradedPluginFile = $options['hook_extra']['plugin']; } else { $this->upgradedPluginFile = null; } return $options; } /** * @access private * * @param mixed $input * @return mixed Returns $input unaltered. */ public function clearUpgradedPlugin($input = null) { $this->upgradedPluginFile = null; return $input; } } endif; if ( !class_exists('SiteSEO_PucFactory', false) ): /** * A factory that builds instances of other classes from this library. * * When multiple versions of the same class have been loaded (e.g. SiteSEOUpdateChecker 1.2 * and 1.3), this factory will always use the latest available version. Register class * versions by calling {@link SiteSEO_PucFactory::addVersion()}. * * At the moment it can only build instances of the SiteSEOUpdateChecker class. Other classes * are intended mainly for internal use and refer directly to specific implementations. If you * want to instantiate one of them anyway, you can use {@link SiteSEO_PucFactory::getLatestClassVersion()} * to get the class name and then create it with <code>new $class(...)</code>. */ #[\AllowDynamicProperties] class SiteSEO_PucFactory { protected static $classVersions = array(); protected static $sorted = false; /** * Create a new instance of SiteSEOUpdateChecker. * * @see SiteSEOUpdateChecker::__construct() * * @param $metadataUrl * @param $pluginFile * @param string $slug * @param int $checkPeriod * @param string $optionName * @param string $muPluginFile * @return SiteSEOUpdateChecker_3_2 */ public static function buildUpdateChecker($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') { $class = self::getLatestClassVersion('SiteSEOUpdateChecker'); return new $class($metadataUrl, $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile); } /** * Get the specific class name for the latest available version of a class. * * @param string $class * @return string|null */ public static function getLatestClassVersion($class) { if ( !self::$sorted ) { self::sortVersions(); } if ( isset(self::$classVersions[$class]) ) { return reset(self::$classVersions[$class]); } else { return null; } } /** * Sort available class versions in descending order (i.e. newest first). */ protected static function sortVersions() { foreach ( self::$classVersions as $class => $versions ) { uksort($versions, array(__CLASS__, 'compareVersions')); self::$classVersions[$class] = $versions; } self::$sorted = true; } protected static function compareVersions($a, $b) { return -version_compare($a, $b); } /** * Register a version of a class. * * @access private This method is only for internal use by the library. * * @param string $generalClass Class name without version numbers, e.g. 'SiteSEOUpdateChecker'. * @param string $versionedClass Actual class name, e.g. 'SiteSEOUpdateChecker_1_2'. * @param string $version Version number, e.g. '1.2'. */ public static function addVersion($generalClass, $versionedClass, $version) { if ( !isset(self::$classVersions[$generalClass]) ) { self::$classVersions[$generalClass] = array(); } self::$classVersions[$generalClass][$version] = $versionedClass; self::$sorted = false; } } endif; //Register classes defined in this file with the factory. SiteSEO_PucFactory::addVersion('SiteSEOUpdateChecker', 'SiteSEOUpdateChecker_3_2', '3.2'); SiteSEO_PucFactory::addVersion('SiteSEOUpdate', 'SiteSEOUpdate_3_2', '3.2'); SiteSEO_PucFactory::addVersion('SiteSEOInfo', 'SiteSEOInfo_3_2', '3.2'); SiteSEO_PucFactory::addVersion('SiteSEO_PucGitHubChecker', 'SiteSEO_PucGitHubChecker_3_2', '3.2'); PK !fh[��Jm:$ :$ custom_fonts.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // custom_fonts.php //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } // This function will handle the custom fonts pages in Pagelayer add_action('init', 'pagelayer_custom_fonts_page', 9999); function pagelayer_custom_fonts_page() { global $pagelayer; // Custom fonts supports $supports = array( 'title', // post title ); // Add custom fonts lables $labels = array( 'name' => _x('Custom Fonts', 'plural'), 'singular_name' => _x('Custom Font', 'singular'), 'menu_name' => _x('Custom Fonts', 'admin menu'), 'name_admin_bar' => _x('Custom Fonts', 'admin bar'), 'add_new' => _x('Add New', 'Add'), 'add_new_item' => __('Add New'), 'new_item' => __('New Font'), 'edit_item' => __('Edit Font'), 'view_item' => __('View Font'), 'all_items' => __('All Fonts'), 'search_items' => __('Search Fonts'), 'not_found' => __('No Pagelayer custom fonts found'), ); $args = array( 'supports' => $supports, 'labels' => $labels, 'public' => false, 'show_in_menu' => false, 'publicly_queryable' => true, 'show_ui' => true, 'exclude_from_search' => true, 'show_in_nav_menus' => false, 'has_archive' => false, 'rewrite' => false, ); // Register custom post type register_post_type(PAGELAYER_FONT_POST_TYPE, $args); remove_post_type_support( PAGELAYER_FONT_POST_TYPE, 'editor'); } // Removing extra columns add_filter( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_columns', 'pagelayer_add_custom_columns' ); function pagelayer_add_custom_columns($columns){ unset( $columns['author'] ); unset( $columns['date'] ); $columns['pl-preview'] = __('Preview'); return $columns; } // Adding preview column data add_action( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_custom_column' , 'pagelayer_add_custom_columns_data', 10, 2 ); function pagelayer_add_custom_columns_data( $column, $post_id ){ if($column == __('pl-preview')){ $font_link = get_post_meta( $post_id, 'pagelayer_font_link', true ); echo '<style>@font-face { font-family: "'.get_the_title($post_id).'"; src: url("'.wp_unslash( $font_link ).'"); }</style>'; echo '<span style="font-family:\''.get_the_title($post_id).'\'; font-size:16px" >Preview of the CUSTOM font</span>'; } } // Removing row actions add_filter( 'post_row_actions', 'pagelayer_remove_row_actions', 10, 1 ); function pagelayer_remove_row_actions( $actions ){ if( get_post_type() === PAGELAYER_FONT_POST_TYPE ){ foreach($actions as $action => $html){ if($action == 'edit' || $action == 'trash' || $action == 'clone' || $action == 'untrash' || $action == 'delete'){ continue; }else{ unset($actions[$action]); } } } return $actions; } // Removing Screen options add_filter('screen_options_show_screen', 'pagelayer_remove_screen_options', 1, 1); function pagelayer_remove_screen_options($show_screen) { if(get_post_type() == PAGELAYER_FONT_POST_TYPE) { return false; } return $show_screen; } // Removing all other metaboxes. add_action('admin_init', function() {pagelayer_remove_all_metaboxes(PAGELAYER_FONT_POST_TYPE);}); function pagelayer_remove_all_metaboxes($type) { add_filter("get_user_option_meta-box-order_{$type}", function() use($type) { global $wp_meta_boxes; $publishbox = $wp_meta_boxes[$type]['side']['core']['submitdiv']; $fontsBox = $wp_meta_boxes[$type]['normal']['default']['pl-fonts-link-box']; $wp_meta_boxes[$type] = array( 'side' => array( 'core' => array( 'submitdiv' => $publishbox ) ), 'normal' => array( 'default' => array( 'pl-fonts-link-box' => $fontsBox ) ) ); return array(); }, PHP_INT_MAX); } // Hiding extra options of publish metabox add_action( 'admin_head', 'pagelayer_hide_publish_options' ); function pagelayer_hide_publish_options() { if(get_post_type() == PAGELAYER_FONT_POST_TYPE){ echo '<style>.submitbox #minor-publishing{ display: none; }</style>'; } } // Adding source metabox add_action('add_meta_boxes', 'pagelayer_add_meta_box'); function pagelayer_add_meta_box(){ add_meta_box( 'pl-fonts-link-box', _x('Source', 'font source'), 'pagelayer_font_link_metabox', PAGELAYER_FONT_POST_TYPE, 'normal', 'default', null); } function pagelayer_font_link_metabox($object){ wp_enqueue_media(); wp_nonce_field('pagelayer-font-post', 'pagelayer'); $link = get_post_meta($object->ID, 'pagelayer_font_link', true); ?> <div> <table width="100%"> <tr> <th valign="top" style="text-align:right; padding-right:20px; width:20%;"><?php echo __('Font File');?> : </th> <td> <div> <input type="text" class="pagelayer_font_input" id="pl_font_link" name="pagelayer_font_link" onclick="fontUpload(event)" style="width:70%" value="<?php echo wp_unslash($link); ?>" autocomplete="false" readonly="true"/> <button type="button" class="button button-light" onclick="fontUpload(event)">Upload Font</button> </div> </td> </tr> </table> </div> <script> window.onload = function(){ jQuery('#submitdiv').on('click', '#publish', function(e){ if(jQuery('#title').val()==''){ alert('Please insert title of the page'); return false; }else{ if(jQuery('#pl_font_link').val()==''){ alert('Please insert link of the font'); return false; }else{ return true; } } }); } function fontUpload(e){ var allowed_mime_type = ['.ttf', '.woff', '.woff2','.otf']; var allClear = false; var custom_uploader = wp.media({ title: 'Upload Font', library : { type : 'font' }, button: { text: 'Select Font' // button label text }, multiple: false }).on('select', function() { // it also has "open" and "close" events var attachment = custom_uploader.state().get('selection').first().toJSON(); for(var i=0; i<allowed_mime_type.length; i++){ if(attachment['filename'].indexOf(allowed_mime_type[i]) != -1){ allClear=true; break; } } if(allClear){ jQuery('.pagelayer_font_input').val(attachment['url']); }else{ alert('Kindly insert a correct font file. Allowed font file types are (otf|ttf|woff|woff2)'); } }).open(); } </script> <?php } // Saving source metabox content add_action('save_post', 'pagelayer_save_source_meta_box', 10, 3); function pagelayer_save_source_meta_box($post_id, $post, $update){ if(PAGELAYER_FONT_POST_TYPE != $post->post_type){ return $post_id; } // DO an admin referrer check if(!empty($_POST)){ check_admin_referer('pagelayer-font-post', 'pagelayer'); }else{ return $post_id; } $meta_box_link_value = ''; if(isset($_POST['pagelayer_font_link'])){ $meta_box_link_value = wp_unslash($_POST['pagelayer_font_link']); } update_post_meta($post_id, 'pagelayer_font_link', $meta_box_link_value ); } // Adding custom mime type add_filter('upload_mimes', 'pagelayer_custom_mime_types', 1, 1); function pagelayer_custom_mime_types($mime_types = array()){ global $pagelayer; forEach($pagelayer->allowed_mime_type as $key => $value){ $mime_types[$key]=$value; } return $mime_types; } // Adding custom mime type add_filter( 'mime_types', 'pagelayer_mime_types' ); function pagelayer_mime_types($default_mimes){ global $pagelayer; forEach($pagelayer->allowed_mime_type as $key => $value){ $default_mimes[$key]=$value; } return $default_mimes; } // Adding custom mime type add_filter( 'wp_check_filetype_and_ext', 'pagelayer_check_filetype_and_ext', 10, 5 ); function pagelayer_check_filetype_and_ext( $types, $file, $filename, $mimes, $real_mime = false ){ global $pagelayer; forEach($pagelayer->allowed_mime_type as $key => $value){ if ( false !== strpos( $filename, '.'.$key ) ) { $types['ext'] = $key; $types['type'] = $value; } } return $types; } // Removing notification. add_filter( 'post_updated_messages', 'pagelayer_delete_notification' ); function pagelayer_delete_notification( $messages ){ if(get_post_type() == PAGELAYER_FONT_POST_TYPE){ unset($messages['post'][1]); unset($messages['post'][6]); return $messages; } } PK !fh[���N �N premium-woocommerce.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } add_action( 'wp', 'pagelayer_pro_wc_customization' ); function pagelayer_pro_wc_customization(){ $options = pagelayer_get_customize_options(); if(!is_product()){ return; } if(!empty($options['woo_enable_product_zoom'] ) && $options['woo_enable_product_zoom'] == 'disable'){ remove_theme_support( 'wc-product-gallery-zoom' ); } if(!empty($options['woo_enable_product_zoom'] ) && $options['woo_enable_product_zoom'] == 'enable'){ add_theme_support( 'wc-product-gallery-zoom' ); } // Disable Product description if(!empty($options['woo_disable_product_desc'])){ remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 ); } // Disable up sell products if(!empty($options['woo_disable_upsells'])){ remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); } // Disable Related Products if(!empty($options['woo_disable_related_product'])){ remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); } } // WooCommerce Checkout Fields Hook add_filter('woocommerce_checkout_fields','pagelayer_wc_checkout_fields_no_label',10); function pagelayer_wc_checkout_fields_no_label($fields) { $options = pagelayer_get_customize_options(); if(empty($options['woo_checkout_label_placeholder'])){ return $fields; } // loop by category foreach ($fields as $category => $value) { // loop by fields foreach ($fields[$category] as $field => $property) { //Add label as placeholder if( $fields[$category][$field]['required'] == true ){ //Add required * in placeholder $fields[$category][$field]['placeholder'] = $fields[$category][$field]['label'] .' *'; }else{ //Add (optional) in placeholder $fields[$category][$field]['placeholder'] = $fields[$category][$field]['label'] .'(optional)'; } // remove label property unset($fields[$category][$field]['label']); } } return $fields; } // Disable sale flash add_filter( 'woocommerce_sale_flash', 'pagelayer_woo_sale_flash', 10, 3 ); function pagelayer_woo_sale_flash( $html, $post, $product ) { $options = pagelayer_get_customize_options(); if(empty($options['woo_disable_onsale'])){ return $html; } return ''; } // Change number of related product on single page add_filter( 'woocommerce_output_related_products_args', 'pagelayer_single_product_number_related_products', 99 ); function pagelayer_single_product_number_related_products( $args ) { $options = pagelayer_get_customize_options(); if(empty($options['woo_number_related_product'])){ return $args; } $args['posts_per_page'] = $options['woo_number_related_product']; // # Of related products if(!empty($options['woo_col_related_product'])){ $args['columns'] = $options['woo_col_related_product']; } return $args; } add_filter( 'pagelayer_wc_styles_array', 'pagelayer_pro_wc_styles_array'); function pagelayer_pro_wc_styles_array($woo_styles){ $styles = array( 'woo_shop_pagi_bg_color' => array( '.woocommerce .woocommerce-pagination ul li a, .woocommerce .woocommerce-pagination a.page-numbers' => 'background-color: {{color}}', ), 'woo_shop_pagi_color' => array( '.woocommerce .woocommerce-pagination ul li a, .woocommerce .woocommerce-pagination a.page-numbers' => 'color: {{color}}', ), 'woo_shop_pagi_borderwidth' => array( '.woocommerce .woocommerce-pagination ul li a, .woocommerce .woocommerce-pagination a.page-numbers' => 'border: {{val}}px solid', '.woocommerce .woocommerce-pagination ul li a:focus, .woocommerce .woocommerce-pagination ul li a:hover, .woocommerce .woocommerce-pagination ul li span.current, .woocommerce .woocommerce-pagination a.page-numbers:hover, .woocommerce .woocommerce-pagination a.page-numbers:focus, .woocommerce .woocommerce-pagination span.page-numbers.current' => 'border: {{val}}px solid', ), 'woo_shop_pagi_border_color' => array( '.woocommerce .woocommerce-pagination ul li a, .woocommerce .woocommerce-pagination a.page-numbers' => 'border-color: {{color}}', ), 'woo_shop_pagi_borderradius' => array( '.woocommerce .woocommerce-pagination ul li a, .woocommerce .woocommerce-pagination a.page-numbers' => 'border-radius: {{val}}px', '.woocommerce .woocommerce-pagination ul li a:focus, .woocommerce .woocommerce-pagination ul li a:hover, .woocommerce .woocommerce-pagination ul li span.current, .woocommerce .woocommerce-pagination a.page-numbers:hover, .woocommerce .woocommerce-pagination a.page-numbers:focus, .woocommerce .woocommerce-pagination span.page-numbers.current' => 'border-radius: {{val}}px', ), 'woo_shop_pagi_bg_hover_color' => array( '.woocommerce .woocommerce-pagination ul li a:focus, .woocommerce .woocommerce-pagination ul li a:hover, .woocommerce .woocommerce-pagination ul li span.current, .woocommerce .woocommerce-pagination a.page-numbers:hover, .woocommerce .woocommerce-pagination a.page-numbers:focus, .woocommerce .woocommerce-pagination span.page-numbers.current' => 'background-color: {{color}}', ), 'woo_shop_pagi_hover_color' => array( '.woocommerce .woocommerce-pagination ul li a:focus, .woocommerce .woocommerce-pagination ul li a:hover, .woocommerce .woocommerce-pagination ul li span.current, .woocommerce .woocommerce-pagination a.page-numbers:hover, .woocommerce .woocommerce-pagination a.page-numbers:focus, .woocommerce .woocommerce-pagination span.page-numbers.current' => 'color: {{color}}', ), 'woo_shop_pagi_hover_border_color' => array( '.woocommerce .woocommerce-pagination ul li a:focus, .woocommerce .woocommerce-pagination ul li a:hover, .woocommerce .woocommerce-pagination ul li span.current, .woocommerce .woocommerce-pagination a.page-numbers:hover, .woocommerce .woocommerce-pagination a.page-numbers:focus, .woocommerce .woocommerce-pagination span.page-numbers.current' => 'border-color: {{color}}', ), 'woo_onsale_bg_color' => array( '.woocommerce .product span.onsale' => 'background-color:{{color}};', ), 'woo_onsale_color' => array( '.woocommerce .product span.onsale' => 'color:{{color}};', ), 'woo_onsale_radius' => array( '.woocommerce .product span.onsale' => 'border-radius:{{color}}%;', ), 'woo_product_breadcrumb_color' => array( '.single-product .woocommerce-breadcrumb, .single-product .woocommerce-breadcrumb *' => 'color: {{color}}' ), 'woo_product_description_color' => array( '.single-product div.product .woocommerce-product-details__short-description, .single-product div.product .woocommerce-product-details__short-description p, .single-product div.product .product_meta, .single-product div.product .entry-content' => 'color: {{color}}' ), 'woo_product_price_color' => array( '.single-product div.product p.price, .single-product div.product span.price' => 'color: {{color}}' ), 'woo_product_title_color' => array( '.single-product .product .entry-title' => 'color: {{color}}' ) ); return array_merge( $woo_styles, $styles ); } add_filter( 'customize_register', 'pagelayer_pro_customizer_get_fields', 11); function pagelayer_pro_customizer_get_fields($wp_customize){ // General Setting $wp_customize->add_setting( 'pagelayer_lable_onsale', array( 'capability' => 'edit_theme_options', )); $wp_customize->add_control( new Pagelayer_Customize_Control( $wp_customize, 'pagelayer_lable_onsale', array( 'type' => 'hidden', 'section' => 'pgl_woo_general', 'description' => __('<div class="pagelayer-customize-heading"><div>Onsale Style</div></div>', 'pagelayer'), 'li_class' => 'pagelayer-accordion-tab', 'priority' => 2 ) )); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_onsale]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_onsale]', array( 'type' => 'checkbox', 'label' => __('Disable Sale Notification'), 'section' => 'pgl_woo_general', 'priority' => 2 )) ); // Adds Customizer settings $wp_customize->add_setting( 'pagelayer_customizer_options[woo_onsale_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_onsale_color]', array( 'label' => __('Sale Text Color'), 'section' => 'pgl_woo_general', 'priority' => 3 ) ) ); // Adds Customizer settings $wp_customize->add_setting( 'pagelayer_customizer_options[woo_onsale_bg_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_onsale_bg_color]', array( 'label' => __('Sale Background'), 'section' => 'pgl_woo_general', 'priority' => 4 ) ) ); // General Setting pagelayer_register_slider_custoze_control($wp_customize, array( 'control' => 'pagelayer_customizer_options[woo_onsale_radius]', 'section' => 'pgl_woo_general', 'setting_type' => 'option', 'label' => __( 'Sale Notification Radius'), 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'priority' => 4, 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ) )); pagelayer_register_slider_custoze_control($wp_customize, array( 'control' => 'pagelayer_customizer_options[woo_product_image_width]', 'section' => 'pgl_woo_single_product', 'setting_type' => 'option', 'label' => __('Image Width'), 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'priority' => 3, 'input_attrs' => array( 'min' => 0, 'max' => 70, 'step' => 1, ) )); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_enable_product_zoom]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( 'pagelayer_customizer_options[woo_enable_product_zoom]', array( 'type' => 'select', 'label' => __('Image Zoom Effect'), 'section' => 'pgl_woo_single_product', 'priority' => 4, 'choices' => array( '' => __('Default'), 'enable' => __('Enable'), 'disable' => __('Disable'), ) ) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_product_desc]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_product_desc]', array( 'type' => 'checkbox', 'label' => __('Hide Products Description'), 'section' => 'pgl_woo_single_product', 'priority' => 5 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_upsells]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_upsells]', array( 'type' => 'checkbox', 'label' => __('Disable Products Up Sells'), 'section' => 'pgl_woo_single_product', 'priority' => 6 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_related_product]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_related_product]', array( 'type' => 'checkbox', 'label' => __('Disable Related Products'), 'section' => 'pgl_woo_single_product', 'priority' => 7 )) ); pagelayer_register_slider_custoze_control($wp_customize, array( 'control' => 'pagelayer_customizer_options[woo_number_related_product]', 'section' => 'pgl_woo_single_product', 'setting_type' => 'option', 'label' => __('No. of Related Products'), 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'priority' => 8, 'input_attrs' => array( 'min' => 1, 'max' => 10, 'step' => 1, ), )); pagelayer_register_slider_custoze_control($wp_customize, array( 'control' => 'pagelayer_customizer_options[woo_col_related_product]', 'section' => 'pgl_woo_single_product', 'setting_type' => 'option', 'label' => __('Related Products columns'), 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'priority' => 8, 'input_attrs' => array( 'min' => 1, 'max' => 6, 'step' => 1, ), )); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_product_title_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_product_title_color]', array( 'label' => __('Title Color'), 'section' => 'pgl_woo_single_product', 'priority' => 9 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_product_price_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_product_price_color]', array( 'label' => __('Price Color'), 'section' => 'pgl_woo_single_product', 'priority' => 10 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_product_description_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_product_description_color]', array( 'label' => __('Description Color'), 'section' => 'pgl_woo_single_product', 'priority' => 11 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_product_breadcrumb_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_product_breadcrumb_color]', array( 'label' => __('Breadcrumb Color'), 'section' => 'pgl_woo_single_product', 'priority' => 12 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_checkout_label_placeholder]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_checkout_label_placeholder]', array( 'type' => 'checkbox', 'label' => __('Show Label as Placeholder'), 'section' => 'pgl_woo_checkout', 'priority' => 4 )) ); // Shop page settings $wp_customize->add_setting( 'pagelayer_lable_shop_pagi', array( 'capability' => 'edit_theme_options', )); $wp_customize->add_control( new Pagelayer_Customize_Control( $wp_customize, 'pagelayer_lable_shop_pagi', array( 'type' => 'hidden', 'section' => 'pgl_woo_product_catalog', 'description' => __('<div class="pagelayer-customize-heading"><div>Pagination Style</div></div>', 'pagelayer'), 'li_class' => 'pagelayer-accordion-tab', 'priority' => 11 ) )); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_shop_pagi_bg_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_shop_pagi_bg_color]', array( 'label' => __('Background Color'), 'section' => 'pgl_woo_product_catalog', 'priority' => 11 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_shop_pagi_bg_hover_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh' ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_shop_pagi_bg_hover_color]', array( 'label' => __('Background Hover Color'), 'section' => 'pgl_woo_product_catalog', 'priority' => 11 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_shop_pagi_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_shop_pagi_color]', array( 'label' => __('Text Color'), 'section' => 'pgl_woo_product_catalog', 'priority' => 11 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_shop_pagi_hover_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_shop_pagi_hover_color]', array( 'label' => __('Text Hover Color'), 'section' => 'pgl_woo_product_catalog', 'priority' => 11 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_shop_pagi_border_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_shop_pagi_border_color]', array( 'label' => __('Border Color'), 'section' => 'pgl_woo_product_catalog', 'priority' => 11 )) ); $wp_customize->add_setting( 'pagelayer_customizer_options[woo_shop_pagi_hover_border_color]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_shop_pagi_hover_border_color]', array( 'label' => __('Border Hover Color'), 'section' => 'pgl_woo_product_catalog', 'priority' => 11 )) ); pagelayer_register_slider_custoze_control($wp_customize, array( 'control' => 'pagelayer_customizer_options[woo_shop_pagi_borderwidth]', 'section' => 'pgl_woo_product_catalog', 'setting_type' => 'option', 'label' => __('Pagination Border Width'), 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'sanitize_callback' => 'absint', 'priority' => 11, 'input_attrs' => array( 'min' => 0, 'max' => 50, 'step' => 1, ), 'responsive' => 1, )); pagelayer_register_slider_custoze_control($wp_customize, array( 'control' => 'pagelayer_customizer_options[woo_shop_pagi_borderradius]', 'section' => 'pgl_woo_product_catalog', 'setting_type' => 'option', 'label' => __('Border Radius'), 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'sanitize_callback' => 'absint', 'priority' => 11, 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), )); }PK !fh[I"�=�u �u template-builder.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // tampalte-builder.php //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } // The function shows the page to add template function pagelayer_builder_template_wizard(){ global $pagelayer; if(!empty($_REQUEST['post'])){ $posts = get_posts([ 'post_type' => $pagelayer->builder['name'], 'post_status' => 'any', 'include' => (int) $_REQUEST['post'], ]); //print_r($posts); // Did we find it ? if(!empty($posts[0])){ $post = $posts[0]; $_post['id'] = $post->ID; $_post['type'] = get_post_meta($post->ID, 'pagelayer_template_type', true); $_post['conditions'] = get_post_meta( $post->ID, 'pagelayer_template_conditions', true ); $_post['post_title'] = $post->post_title; } } // Fill in defaults if nothing found if(empty($_post)){ $_post['id'] = 0; $_post['type'] = ''; $_post['post_title'] = ''; $_post['conditions'] = []; } ?> <style> .pagelayer-temp-search-sel-open{ float: right; font-size: 10px; padding: 0px; line-height: 20px; } .pagelayer-temp-search-sel-remove{ position: absolute; right: 20px; font-size: 11px; top: 10px; z-index: 10; } .pagelayer-temp-search-sel-span{ display: block; margin: 2px; cursor: pointer; box-sizing: border-box; border: 1px solid #dbdbdb; transition: all 0.3s; font-size: 13px; padding: 3px; } .pagelayer-temp-search-sel-span:hover{ border-color: #00A0D2; background-color: #3e8ef7; color: #ffffff; box-shadow: 0px 1px 1px #3e8ef7bf; } .pagelayer-temp-search-sel-span i{ font-size: 15px; line-height: 1em; padding: 3px; color: #555; transition: all 0.3s; vertical-align: middle; } .pagelayer-temp-search-sel-span:hover i{ color: #ffffff; } .pagelayer-temp-search-sel{ vertical-align: top } .pagelayer-temp-toggle{ cursor:pointer; } .pagelayer-temp-label{ display:block; margin-bottom:5px; } .pagelayer-temp-fields{ display:inline-block; position:relative; margin:0 3px; } .pagelayer-temp-condition{ border:1px solid #d0d0d0; margin-bottom:10px; } .pagelayer-temp-tab{ padding: 6px 10px; background: #d0d0d0; display: flow-root; } .pagelayer-temp-condition-div{ padding:10px; } .pagelayer-temp-hide{ display:none; } .pagelayer-temp-search-holder{ position:relative; display:inline-block; } .pagelayer-temp-search-div{ cursor: pointer; padding: 5px; border: solid 1px #d1d1d1; background: #fffffc; color: #333; vertical-align: middle; width: 126px; display: flex; /* min-width: 245px; border-radius: 4px; margin: 0 auto; position: absolute; top: 7px; */ } .pagelayer-temp-search-preview{ position: relative; margin-right: 5px; width: 100%; border: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .pagelayer-temp-search-preview i{ padding-right: 5px; font-size: 19px; color: #666; vertical-align: middle; } .pagelayer-temp-search-name{ font-size: 13px; } .pagelayer-temp-search-selector{ position: absolute; z-index: 1000; border: 1px solid rgba(0,0,0,0.2) !important; background: #fff !important; box-shadow: 0 3px 5px rgba(0,0,0,0.2) !important; -webkit-border-radius: 2px !important; text-shadow: none !important; padding: 5px; height: auto; box-sizing: border-box; display: none; width: 100%; border-radius: 2px; margin: 0 0 0 auto; top: 35px; } .pagelayer-temp-search-val{ margin-bottom: 5px !important; padding: 2px 6px; line-height: 20px !important; border-radius: 3px !important; width: 100%; } .pagelayer-temp-search-list{ width: 100%; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; padding: 0; max-height: 183px; overflow-y: auto; } .pagelayer-temp-close{ float:right; font-size:15px; } .pagelayer-close-condition{ font-size: 15px; font-weight: 900; height:7px; margin-top: -2px; padding-left:5px; padding-right:5px; float:right; cursor: pointer; } .pagelayer-temp-add-new, .pagelayer-temp-submit-btn{ font-size: 14px; font-weight: bold; cursor: pointer; border-radius: 2px; padding: 4px 8px; border: #398439 1px solid; color: #fff; background: #449d44; } .pagelayer-temp-pad5{ padding-left:5px; padding-right:5px; } .pagelayer-temp-container{ background-color:#fff; padding:0px; width:95%; border-radius: 4px; margin: 10px auto; } .pagelayer-temp-head{ padding:10px; font-weight:bold; border-bottom: 1px solid #dfdfdf; } .pagelayer-temp-row{ display:table-cell; padding: 10px; } .pagelayer-temp-condition-holder{ padding: 0px 10px; display: none; } .pagelayer-temp-submit{ padding: 10px; } .pagelayer-temp-container select{ font-size:13px; } .postbox{ margin-bottom:5px; } </style> <?php $sel_type = $_post['type']; $dis_conditions = $_post['conditions']; echo ' <div class="pagelayer-temp-container"> <div class="pagelayer-temp-head"> <img src="'.PAGELAYER_URL.'/images/pagelayer-logo-19.png'.'" style="vertical-align: top;" /> '; if(empty($_post['type'])){ echo __pl('add_temp'); }else{ echo __pl('edit_temp').'<span style="float:right" class="pagelayer-temp-edit"><a href="'.esc_url( pagelayer_shortlink($_post['id']).'&pagelayer-live=1' ).'">'.__pl('edit_using').'</a></span>'; } echo ' </div> <div class="pagelayer-temp-row"> <label class="pagelayer-temp-label">'.__('Select Template Type :').'</label> <select name="pagelayer_template_type" class="postbox"> '.pagelayer_create_sel_options( $pagelayer->builder["type"], $sel_type ).' </select> </div> <div class="pagelayer-temp-row"> <label for="pagelayer_lib_title" class="pagelayer-temp-label">'.__('Name :').'</label> <input type="text" name="pagelayer_lib_title" size="30" value="'.$_post['post_title'].'" /> </div> <div class="pagelayer-temp-condition-holder '.((!empty($pagelayer->builder["type"][$sel_type]['no_condition'])) ? ' pagelayer-temp-hide' : '').'"> <label class="pagelayer-temp-label">'.__('Template Display Conditions :').'</label> <div class="pagelayer-temp-condition-container">'; if( !empty($dis_conditions) ){ foreach($dis_conditions as $condi){ echo ' <div class="pagelayer-temp-condition"> <div class="pagelayer-temp-tab"> <span class="pagelayer-temp-toggle pagelayer-temp-pad5">☰</span> <span>'. __('Display Conditions').'</span> <span class="pagelayer-close-condition">×</span> </div> <div class="pagelayer-temp-condition-div"> <div class="pagelayer-temp-fields"> <label for="pagelayer_condition_type" class="pagelayer-temp-label">'. __('Action Type :').'</label> <select name="pagelayer_condition_type[]" class="postbox"> '.pagelayer_create_sel_options( $pagelayer->builder["action"], $condi['type'] ).' </select> </div> <div class="pagelayer-temp-fields"> <label for="pagelayer_condition_name" class="pagelayer-temp-label"> '. __('Display On : ').'</label> <select name="pagelayer_condition_name[]" class="postbox"> '.pagelayer_create_sel_options( $pagelayer->builder['dispay_on'], $condi['template'] ).' </select> </div> <div class="pagelayer-temp-fields '.(empty($condi['template']) ? 'pagelayer-temp-hide' : '').'"> <label for="pagelayer_condition_sub_template" class="pagelayer-temp-label"> '. __('Template : ').'</label> <select name="pagelayer_condition_sub_template[]" class="postbox">'; if($condi['template'] == 'archives'){ echo pagelayer_create_sel_options( $pagelayer->builder['archives_templates'], $condi['sub_template'] ); }else{ echo pagelayer_create_sel_options( $pagelayer->builder['singular_templates'], $condi['sub_template'] ); } echo ' </select> </div> <div class="pagelayer-temp-fields pagelayer-temp-search-sel '. ((empty($condi['sub_template'])) ? ' pagelayer-temp-hide' : '').'"> <label for="pagelayer_condition_id" class="pagelayer-temp-label">'.__('Specific Items').'</label>'; $req_arr['id'] = $condi['id']; $req_arr['filter_type'] = 'post'; if( is_numeric(strpos($condi['sub_template'] , 'author'))){ $req_arr['filter_type'] = 'author'; } if( is_numeric(strpos($condi['sub_template'] , 'category')) || is_numeric(strpos($condi['sub_template'] , 'tag')) ){ $req_arr['filter_type'] = 'taxonomy'; } $title_array = pagelayer_builder_get_title($req_arr['filter_type'], $req_arr['id']); $id = ''; $title = ''; foreach ( $title_array as $tmp_id => $tmp_title ) { $id = $tmp_id; $title = $tmp_title; } echo ' <select name="pagelayer_condition_id[]" class="postbox pagelayer-temp-hide"> <option selected value="'. ((empty($id)) ? '' : $id).'"> '. ((empty($title)) ? __('All') : $title).'</option> </select> <div class="pagelayer-temp-search-holder"> <div class="pagelayer-temp-search-div"> <div class="pagelayer-temp-search-preview"> <span class="pagelayer-temp-search-name"> '. ((empty($title)) ? __('All') : $title).' </span> <span class="pagelayer-temp-close '. ((empty($title)) ? ' pagelayer-temp-hide' : '').'">×</span> </div> <span class="">⯆</span> </div> <div class="pagelayer-temp-search-selector"> <input autocomplete="off" type="text" class="pagelayer-temp-search-val" name="search-icon" placeholder="Search"> <div class="pagelayer-temp-search-list"> </div> </div> </div> </div> </div> </div>'; } } echo ' </div> <div style="margin:15px 10px;"> <span class="pagelayer-temp-add-new" >'. __('Add Conditions').'</span> </div> </div> <div class="pagelayer-temp-submit"> <center><button type="submit" class="pagelayer-temp-submit-btn button button-primary">'.__('Save Template').'</button></center> </div> </div> <script type="text/javascript"> pagelayer_cpt = '.json_encode($pagelayer->builder).'; pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?"; pagelayer_builder_nonce = "'.wp_create_nonce('pagelayer_builder').'"; </script>'; ?> <script type="text/javascript"> jQuery(document).ready(function(){ var $ = jQuery; if(typeof pagelayer !== 'undefined'){ var $ = pagelayer.$$ || $; } // The container var pl_temp = $(".pagelayer-temp-container"); var pl_condi = pl_temp.find('.pagelayer-temp-condition-holder'); // Get values from multi-dimensional array by key var pagelayer_multi_array_search = function(array = [], key){ var array_key = []; if (key in array) { array_key = array[key]; } for( var k in array) { if (typeof array[k] === 'object' && key in array[k]) { array_key = array[k][key]; } } return array_key; } // Creates the select options var create_options = function(opt_array){ var options = ''; var tmp_numeric = ''; // Required to handle key 404 in singular templates as json decode puts number first and that spoils our order for (x in opt_array){ // Single item if(typeof opt_array[x] == 'string'){ options += option(x, opt_array[x]); if(tmp_numeric.length > 0){ options += tmp_numeric; tmp_numeric = ''; } // If is array then we get the label string }else if(typeof opt_array[x] == 'object'){ if('label' in opt_array[x]){ if(x == 404){ tmp_numeric = option(x, opt_array[x]['label']); continue; } options += option(x, opt_array[x]['label']); // Groups }else{ options += '<optgroup label="'+x+'">'; options += create_options(opt_array[x]); options += '</optgroup>'; } } } return options; } var option = function(val, lang){ return '<option value="'+val+'">'+lang+'</option>'; } var html_condi = '<div class="pagelayer-temp-condition">'+ '<div class="pagelayer-temp-tab">'+ '<span class="pagelayer-temp-toggle pagelayer-temp-pad5">☰</span>'+ '<span>'+<?php echo "'".__('Display Conditions')."'";?>+'</span>'+ '<span class="pagelayer-close-condition">×</span>'+ '</div>'+ '<div class="pagelayer-temp-condition-div">'+ '<div class="pagelayer-temp-fields">'+ '<label for="pagelayer_condition_type" class="pagelayer-temp-label">'+<?php echo "'".__('Action Type')."'";?>+'</label>'+ '<select name="pagelayer_condition_type[]" class="postbox">'+ create_options(pagelayer_cpt["action"])+ '</select>'+ '</div>'+ ' <div class="pagelayer-temp-fields">'+ '<label for="pagelayer_condition_name" class="pagelayer-temp-label">'+<?php echo "'".__('Display On')."'";?>+'</label>'+ '<select name="pagelayer_condition_name[]" class="postbox">'+ create_options(pagelayer_cpt["dispay_on"])+ '</select>'+ '</div>'+ ' <div class="pagelayer-temp-fields pagelayer-temp-hide">'+ '<label for="pagelayer_condition_sub_template" class="pagelayer-temp-label">'+<?php echo "'".__('Template')."'";?>+'</label>'+ '<select name="pagelayer_condition_sub_template[]" class="postbox">'+ '</select>'+ '</div>'+ ' <div class="pagelayer-temp-fields pagelayer-temp-hide pagelayer-temp-search-sel">'+ '<label for="pagelayer_condition_id" class="pagelayer-temp-label">'+<?php echo "'".__('Specific Items')."'";?>+'</label>'+ '<select name="pagelayer_condition_id[]" class="postbox pagelayer-temp-hide">'+ '<option selected value="">All</option>'+ '</select>'+ '<div class="pagelayer-temp-search-holder">'+ '<div class="pagelayer-temp-search-div">'+ '<div class="pagelayer-temp-search-preview">'+ '<span class="pagelayer-temp-search-name">All</span>'+ '<span class="pagelayer-temp-close pagelayer-temp-hide">×</span>'+ '</div>'+ '<span class="">⯆</span>'+ '</div>'+ '<div class="pagelayer-temp-search-selector">'+ '<input autocomplete="off" type="text" class="pagelayer-temp-search-val" name="search-icon" placeholder="Search">'+ '<div class="pagelayer-temp-search-list">'+ '</div>'+ '</div>'+ '</div>'+ '</div>'+ '</div>'+ '</div>'; // Removes a condition var close_tab = function(){ var condi = pl_temp.find(".pagelayer-temp-condition"); condi.find(".pagelayer-close-condition").click(function(){ jQuery(this).closest(".pagelayer-temp-condition").remove(); }); }; // Toggle a condition content var toggle_tab = function(){ var condi = pl_temp.find(".pagelayer-temp-condition"); condi.find(".pagelayer-temp-tab").unbind("click"); condi.find(".pagelayer-temp-tab").click(function(){ jQuery(this).closest(".pagelayer-temp-condition").find(".pagelayer-temp-condition-div").toggle(); }); }; // Opens the search selector var open_search = function(){ var el = pl_temp.find('.pagelayer-temp-search-div') el.unbind('click'); el.on('click', function(){ jQuery(this).parent().find('.pagelayer-temp-search-selector').slideToggle(); }); }; var pagelayer_set_inter; // A timer // Get closest select box by name in closest "pagelayer-temp-condition" class var pagelayer_get_closest_sel = function(jEle, name){ return jEle.closest(".pagelayer-temp-condition").find("[name='"+name+"']"); } // Handle search of values var search_list = function(){ pl_temp.find('.pagelayer-temp-search-val').on('keyup', function(){ var v = this.value; var iEle = jQuery(this); var template_name, ele_name, template_name_array; //v = v.replace(/\s+/g, '-'); template_name = pagelayer_get_closest_sel(iEle, 'pagelayer_condition_name[]').val(); ele_name = pagelayer_get_closest_sel(iEle, 'pagelayer_condition_sub_template[]').val(); template_name_array = pagelayer_multi_array_search(pagelayer_cpt[template_name+'_templates'], ele_name); data_array = { pagelayer_nonce: pagelayer_builder_nonce, search : v, filter_type : template_name_array['filter_type'] || 'post', object_type : template_name_array['object_type'] || 'post', }; clearTimeout(pagelayer_set_inter); pagelayer_set_inter = setTimeout(function () { v = v.toLowerCase(); jQuery.ajax({ url: pagelayer_ajax_url+'&action=pagelayer_search_ids', type: 'post', data : data_array, success:function(response){ iEle.next().html(response); //console.log(response); } }); //row.find('.pagelayer-temp-search-list').empty().html(span); }, 200); }); // Handle click within the ID selector pl_temp.find('.pagelayer-temp-search-selector').unbind('click'); pl_temp.find('.pagelayer-temp-search-selector').on('click', function(e){ var jEle = jQuery(e.target); var val = jEle.attr('value'); var text = jEle.text(); if(val.length < 1 || text.length < 1){ return false; } // Set the ID in this list var row = jEle.closest('.pagelayer-temp-search-sel'); row.find('[name="pagelayer_condition_id[]"]').html('<option selected value="'+ val +'">'+ text +'</option>'); row.find('.pagelayer-temp-search-preview .pagelayer-temp-search-name').text(text).next().show(); row.find('.pagelayer-temp-search-selector').slideUp(); return false; }); pl_temp.find('.pagelayer-temp-close').click(function(e){ e.stopPropagation(); var sHold = jQuery(this).closest('.pagelayer-temp-search-sel'); sHold.find('[name="pagelayer_condition_id[]"]').html('<option selected value="">All</option>'); sHold.find('.pagelayer-temp-search-preview .pagelayer-temp-search-name').text('All').next().hide(); }); }; // Whenever a condition is to be initialized var reinit_conditions = function(){ close_tab(); toggle_tab(); open_search(); search_list(); pl_temp.find('select').unbind('change'); pl_temp.find('select').on('change', function(event, triggerEle){ var sEle = jQuery(this); var sVal = sEle.val(); var condiEle = triggerEle || pl_condi; //console.log(sVal); // Hide search box if any select is changed var temp_search = jQuery('.pagelayer-temp-search-selector'); if(temp_search.is(':visible') || jQuery('.pagelayer-temp-search-preview > .pagelayer-temp-close').is(':visible')){ temp_search.hide(); temp_search.find('.pagelayer-temp-search-list').empty(); temp_search.find('.pagelayer-temp-search-val').val(''); } switch(sEle.attr('name')){ case 'pagelayer_template_type': var no_condition = pagelayer_cpt["type"][sVal]['no_condition'] || false; if( no_condition ){ pl_condi.hide(); }else if(!pl_condi.is(':visible')){ pl_condi.show(); } condiEle.find("[name='pagelayer_condition_name[]']").each(function(){ var condi_name = jQuery(this); var need_selection = pagelayer_multi_array_search(pagelayer_cpt["type"], sVal); if(typeof need_selection === 'object' && 'need_selection' in need_selection){ if(need_selection['need_selection'] != condi_name.val() ){ condi_name.val(need_selection['need_selection']).trigger('change'); } condi_name.css('pointer-events', 'none'); }else if(condi_name.css('pointer-events') == 'none'){ condi_name.css('pointer-events', 'all'); } }); break; case 'pagelayer_condition_type[]': //console.log(sEle.val()); break; case 'pagelayer_condition_name[]': var ele_name = pagelayer_get_closest_sel(sEle, 'pagelayer_condition_sub_template[]'); //console.log(sEle.val()); if(sVal.length == 0){ ele_name.closest(".pagelayer-temp-fields").addClass('pagelayer-temp-hide'); }else{ if(pagelayer_cpt[sVal+"_templates"]){ ele_name.html(create_options(pagelayer_cpt[sVal+"_templates"])); ele_name.closest(".pagelayer-temp-fields").removeClass('pagelayer-temp-hide'); } } ele_name.trigger('change'); break; case 'pagelayer_condition_sub_template[]': // Get selected template name var template_name = pagelayer_get_closest_sel(sEle, 'pagelayer_condition_name[]').val(); var ele_name = pagelayer_get_closest_sel(sEle, 'pagelayer_condition_id[]'); var template_name_array = pagelayer_multi_array_search(pagelayer_cpt[template_name+'_templates'], sVal); if(sVal.length == 0 || template_name_array['no_id_section'] || !sEle.is(':visible')){ ele_name.closest(".pagelayer-temp-fields").addClass('pagelayer-temp-hide'); }else{ ele_name.closest(".pagelayer-temp-fields").removeClass('pagelayer-temp-hide'); } ele_name.closest(".pagelayer-temp-fields").find('.pagelayer-temp-close').click(); break; case 'pagelayer_condition_id[]': //console.log(sEle.val()); break; } }); } reinit_conditions(); <?php if(!empty($_post['id'])){ $sub_template_sel = "'pagelayer_condition_sub_template[]'"; echo ' //reinit_conditions(); pl_condi.show(); pl_temp.find("select[name=pagelayer_template_type]").trigger("change"); pl_temp.find("select[name='.$sub_template_sel.']").trigger("change"); pl_temp.find("select[name=pagelayer_template_type]").prop("disabled", true); //pl_condi.find("select").trigger("change")'; } ?> // On click add more condition pl_temp.find(".pagelayer-temp-add-new").click(function(){ pl_condi.show(); var hEle = jQuery(html_condi); pl_temp.find('.pagelayer-temp-condition-container').append(hEle); reinit_conditions(); pl_temp.find('select[name="pagelayer_template_type"]').trigger('change', [hEle]); }); // Save the template pl_temp.find(".pagelayer-temp-submit-btn").click(function(e){ e.preventDefault(); var data = pl_temp.find('input, select, textarea').serialize(); //alert(data); jQuery.ajax({ url: pagelayer_ajax_url+'&action=pagelayer_save_template&postID='+ <?php echo "'".$_post['id']."'";?>, type: 'post', data : 'pagelayer_nonce='+ pagelayer_builder_nonce +'&'+ data, success: function(response, status, xhr){ var obj = jQuery.parseJSON(response); //alert(obj); if(obj['error']){ alert(obj['error']); }else{ alert(obj['success']); var hasPost = new window.URLSearchParams(window.location.search).has('post'); if(!hasPost){ window.location.replace(window.location+'&post='+obj['id']); } } }, error: function(errorThrown){ alert(errorThrown); console.log(errorThrown); } }); }); }); </script> <?php } // Get Title from ID function pagelayer_builder_get_title($type, $ids = array()){ $ids = (array) $ids; $sel_title = []; switch ( $type ) { case 'taxonomy': $terms = get_terms([ 'include' => $ids, 'hide_empty' => false, ]); global $wp_taxonomies; foreach ( $terms as $term ) { $sel_title[ $term->term_taxonomy_id ] = $term->name ; } break; case 'post': $query = new \WP_Query([ 'post_type' => 'any', 'post__in' => $ids, 'posts_per_page' => -1, 'post_status' => 'any', ]); foreach ( $query->posts as $post ) { $sel_title[ $post->ID ] = $post->post_title; } break; case 'author': $query_params = [ 'capability' => array( 'edit_posts' ), 'fields' => ['ID', 'display_name'], 'include' => $ids, ]; // Capability queries were only introduced in WP 5.9. if( version_compare( $GLOBALS['wp_version'], '5.9-alpha', '<' ) ){ $args['who'] = 'authors'; unset( $args['capability'] ); } $user_query = new \WP_User_Query( $query_params ); foreach ( $user_query->get_results() as $author ) { $sel_title[ $author->ID ] = $author->display_name; } break; } return $sel_title; } // Append the Popup templates function pagelayer_builder_popup_append(){ global $pagelayer; if(!empty($GLOBALS['pagelayer_builder_popup_append_called'])){ return; } $GLOBALS['pagelayer_builder_popup_append_called'] = 1; // Render the multiple Popups foreach($pagelayer->template_popup_ids as $id => $priority){ $bLoadString = ''; $content = pagelayer_get_post_content($id); // For popup before loading option // First check that att is placed or not. Then scan and extract the value of id and insert it into bLoadString variable if(strpos($content, 'data-trig_before_load') !== false){ preg_match('#pagelayer-id=([^\s]+)#', $content, $matches); $bLoadString = 'pagelayer-popup-Shown="1" style="display: flex;" pagelayer-popup-id="'.$matches[1].'"'; } echo '<div class="pagelayer-popup-modal" '.$bLoadString.'> <div class="pagelayer-popup-modal-content"> <div class="pagelayer-popup-content"> '.$content.' </div> </div> </div>'; } } // Export Pages, Media and Pagelayer Template Files function pagelayer_builder_export($type){ global $pagelayer; // Load the templates pagelayer_builder_load_templates(); $data['page'] = []; // Load the other posts foreach($pagelayer->settings['post_types'] as $type){ // Make the query $type_query = new WP_Query(['post_type' => $type, 'status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'name', 'order' => 'ASC']); $data[$type] = $type_query->posts; } $nonce = wp_create_nonce('pagelayer_builder'); echo '<h1>Pagelayer - Export Template into a Theme</h1> <span style="font-size:12px">With this wizard you can export Pagelayer Template(s) (and pages) into a theme folder. This theme folder can be distributed as a theme and can be used by any Pagelayer user.</span>'; // Make two tables echo ' <script> pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?"; function pagelayer_checkbox(ele, cl){ var jEle = jQuery(ele); jQuery(cl).prop("checked", jEle.prop("checked")); } function pagelayer_export_template(){ var data = jQuery("#pagelayer_export_template_form").serialize(); //console.log(data); jQuery.ajax({ dataType: "json", url: pagelayer_ajax_url+"&action=pagelayer_export_template", type: "post", data: data, success:function(response){ if("success" in response){ alert(response["success"]); } if("error" in response){ alert(response["error"]); } } }); return false; } </script> <form id="pagelayer_export_template_form"> <input type="hidden" name="pagelayer_nonce" value="'.$nonce.'"> <div style="display:flex; flex-wrap: wrap; width:100%;"> <div style="width:50%; padding: 10px;"> <h2>Pagelayer Templates</h2> <table cellspacing="0" cellpadding="8" border="0" width="100%" class="wp-list-table widefat fixed striped"> <tr> <td width="10"><input type="checkbox" onclick="pagelayer_checkbox(this, \'.pagelayer_temp_cb\');"></td> <td>Title</td> <td>Type</td> <td>Display On</td> </tr>'; foreach($pagelayer->templates as $k => $v){ $type = get_post_meta($v->ID, 'pagelayer_template_type', true); $dis_conditions = get_post_meta( $v->ID, 'pagelayer_template_conditions', true ); $dis_html = 'None'; if( !empty($dis_conditions) ){ $dis_html = ''; foreach($dis_conditions as $condi){ $dis_html .= '<span>'; if(isset($condi['template'])){ $template = pagelayer_multi_array_search($pagelayer->builder['dispay_on'], $condi['template']); if(is_array($template) && array_key_exists('label', $template)){ $template = $template['label']; } $dis_html .= $template; } if(isset($condi['sub_template'])){ $sub_template = pagelayer_multi_array_search($pagelayer->builder[$condi['template'].'_templates'], $condi['sub_template']); if(is_array($sub_template) && array_key_exists('label', $sub_template)){ $sub_template = $sub_template['label']; } if(!empty($sub_template)){ $dis_html .= ' > '. $sub_template; } } if(!empty($condi['id'])){ $dis_html .= ' > #'. $condi['id']; } $dis_html .= '</span></br>'; } } //print_r($v); echo ' <tr> <td><input type="checkbox" class="pagelayer_temp_cb" name="templates['.$v->ID.']"></td> <td>'.$v->post_title.'</td> <td>'.(!empty($pagelayer->builder['type'][$type]['label']) ? $pagelayer->builder['type'][$type]['label'] : $pagelayer->builder['type'][$type]).'</td> <td>'.$dis_html.'</td> </tr>'; } echo ' </table> </div>'; $pt_objects = get_post_types(['public' => true], 'objects'); foreach($data as $type => $d){ if(empty($pt_objects[$type])){ continue; } echo ' <div style="width:22%; padding: 10px;"> <h2>'.$pt_objects[$type]->labels->name.'</h2> <table cellspacing="0" cellpadding="8" border="0" width="100%" class="wp-list-table widefat fixed striped"> <tr> <td width="10"><input type="checkbox" onclick="pagelayer_checkbox(this, \'.pagelayer_'.$type.'_cb\');"></td> <td>Title</td> <td width="80">Type</td> </tr>'; foreach($data[$type] as $k => $v){ //$type = get_post_meta($v->ID, 'pagelayer_template_type', true); //print_r($v); echo ' <tr> <td><input type="checkbox" class="pagelayer_'.$type.'_cb" name="'.$type.'['.$v->ID.']"></td> <td>'.$v->post_title.'</td> <td>'.$pt_objects[$type]->labels->name.'</td> </tr>'; } echo ' </table> </div>'; } echo ' </div> <div class="pagelayer-temp-submit"> <center> <button onclick="return pagelayer_export_template()" class="pagelayer-temp-submit-btn button button-primary">'.__('Export Template Files').'</button> </center> </div> </form>'; }PK !fh[���$�t �t premium_functions.phpnu �[��� <?php ////////////////////////////////////////////////////////////// //=========================================================== // class.php //=========================================================== // PAGELAYER // Inspired by the DESIRE to be the BEST OF ALL // ---------------------------------------------------------- // Started by: Pulkit Gupta // Date: 23rd Jan 2017 // Time: 23:00 hrs // Site: http://pagelayer.com/wordpress (PAGELAYER) // ---------------------------------------------------------- // Please Read the Terms of use at http://pagelayer.com/tos // ---------------------------------------------------------- //=========================================================== // (c)Pagelayer Team //=========================================================== ////////////////////////////////////////////////////////////// // Are we being accessed directly ? if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } // Audio Handler function pagelayer_sc_audio(&$el){ global $pagelayer; if(empty($pagelayer->sc_audio_enqueued) && !pagelayer_is_live_iframe()){ wp_enqueue_script('wp-mediaelement'); wp_enqueue_style( 'wp-mediaelement' ); $pagelayer->sc_audio_enqueued = 1; } return; $el['atts']['a_url'] = ''; if ($el['atts']['source'] == 'external'){ $el['atts']['a_url'] = $el['atts']['url']; } if ($el['atts']['source'] == 'library'){ $el['atts']['a_url'] = wp_get_attachment_url($el['atts']['id']); } if(!empty($el['atts']['a_url'])){ $filename=$el['atts']['a_url']; //Get the file extension $extension = pathinfo($filename, PATHINFO_EXTENSION); //Create source tag according to audio file switch($extension){ default: case 'mp3': $el['atts']['a_type'] = 'audio/mpeg'; break; case 'ogg': $el['atts']['a_type']= 'audio/ogg'; break; case 'wav': $el['atts']['a_type'] = 'audio/wav'; break; } } if(!empty($el['atts']['a_url']) && !empty($el['atts']['a_type'])){ $el['attr'][]= ['source' => 'src="{{a_url}}']; $el['attr'][]= ['source' => 'type="{{a_type}}']; } } // Image Portfolio function pagelayer_sc_single_img(&$el){ // Decide the image URL $img_size = pagelayer_isset($el['atts'], 'img-size'); $el['atts']['func_img'] = pagelayer_isset($el['tmp'], 'img-'.$img_size.'-url'); $el['atts']['func_img'] = empty($el['atts']['func_img']) ? pagelayer_isset($el['tmp'], 'img-url') : $el['atts']['func_img']; // What is the link ? if(!empty($el['atts']['link_type'])){ // Custom url if($el['atts']['link_type'] == 'custom_url'){ // Backward compatibility for new link props pagelayer_add_link_backward($el, array( 'rel' => '', 'selector' => '.pagelayer-ele-link')); $el['atts']['func_link'] = empty($el['tmp']['link']) ? '' : $el['tmp']['link']; } // Link to the media file itself if($el['atts']['link_type'] == 'media_file'){ $el['atts']['func_link'] = $el['atts']['func_img']; } // Lightbox if($el['atts']['link_type'] == 'lightbox'){ $el['atts']['func_link'] = $el['atts']['func_img']; } } } // Posts Grid function pagelayer_sc_wp_posts_grid($atts, $content = '', $tag = ''){ $args = array( 'numberposts' => -1, 'post_type' => 'post', 'post_status' => array('publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash') ); $all_posts = get_posts($args); $html = '<div '.pagelayer_create_sc($tag, $atts, 'pagelayer-posts-grid').'>'; //pagelayer_print($all_posts); foreach($all_posts as $pk => $pv){ $post_link = get_permalink($pv->ID); $html .= '<div> <h2><a href="'.$post_link.'">'.$pv->post_title.'</a></h2> <p>'.date('F jS, Y', strtotime($pv->post_date)).' | Published by <a href="'.site_url('author/'.get_the_author_meta('user_login', $pv->post_author)).'">'.get_the_author_meta('display_name', $pv->post_author).'</a></p> <p>'.pagelayer_the_content($pv->post_content).'</p> <p><a href="'.$post_link.'">Read More</a></p> </div>'; } $html .= '</div>'; return $html; } // Posts Slider function pagelayer_sc_wp_posts_slider(&$el){ $params = array(); $params['post'] = array(); if($el['atts']['post_type']) $params['post']['post_type'] = $el['atts']['post_type']; if($el['atts']['post_count']) $params['post']['post_count'] = $el['atts']['post_count']; if($el['atts']['category']) $params['post']['category'] = $el['atts']['category']; if($el['atts']['tags']) $params['post']['tags'] = $el['atts']['tags']; if($el['atts']['order_by']) $params['post']['order_by'] = $el['atts']['order_by']; if($el['atts']['sort_order']) $params['post']['sort_order'] = $el['atts']['sort_order']; if($el['atts']['image_size']) $params['post']['image_size'] = $el['atts']['image_size']; if($el['atts']['show_excerpt']) $params['post']['show_excerpt'] = $el['atts']['show_excerpt']; $el['atts']['posts_slides'] = pagelayer_posts_slider($params); //wp_reset_postdata(); } // Search function function pagelayer_sc_search(&$el){ if(!empty($el['atts']['placeholder'])){ $el['tmp']['placeholder'] = htmlspecialchars($el['atts']['placeholder']); } } // Post portfolio function pagelayer_sc_post_folio(&$el){ $args = array(); if($el['atts']['type']) $args['post_type'] = $el['atts']['type']; // Filter by if($el['atts']['filter_by']) $args['filter_by'] = $el['atts']['filter_by']; // Page count if($el['atts']['count']) $args['posts_per_page'] = $el['atts']['count']; $el['atts']['post_html'] = pagelayer_widget_posts($args); } // Posts Handler function pagelayer_sc_posts(&$el){ global $pagelayer; $allow_param = array('show_thumb', 'thumb_size', 'show_content', 'show_title', 'more', 'btn_type', 'size', 'icon_position', 'icon', 'show_more', 'meta_sep', 'exc_length', 'post_type', 'exc_term', 'exc_author', 'offset','ignore_sticky', 'orderby', 'by_period', 'before_date', 'after_date', 'thumb_img_type', 'infinite_types' ); $param = array(); // Page count $param['posts_per_page'] = !empty($el['atts']['count']) ? $el['atts']['count'] : ''; $param['order'] = !empty($el['atts']['posts_order']) ? $el['atts']['posts_order'] : ''; $param['term'] = !empty($el['atts']['inc_term']) ? $el['atts']['inc_term'] : ''; $param['author_name'] = !empty($el['atts']['inc_author']) ? $el['atts']['inc_author'] : ''; if(!empty($el['atts']['thumb_img_type'])){ $thumb_size = pagelayer_isset($el['atts'], 'thumb_size'); $img_size = pagelayer_isset($el['tmp'], 'def_thumb_img-'.$thumb_size.'-url'); $param['def_thumb_img'] = empty($img_size) ? pagelayer_isset($el['tmp'], 'def_thumb_img-url') : $img_size; } foreach($allow_param as $val){ $param[$val] = !empty($el['atts'][$val]) ? $el['atts'][$val] : ''; } if(!empty($el['atts']['meta'])){ $meta_arr = explode(',',$el['atts']['meta']); //pagelayer_print($el['atts']['meta']); foreach($meta_arr as $arr){ $param[$arr] = $arr; } } if(wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'pagelayer_infinite_posts'){ $param['paged'] = $el['atts']['paged']; }else{ $data = array('tag' => $el['tag'],'atts' => $el['oAtts']); $pagelayer->localScript['pagelayer_post_'.$el['id']] = $data; } //pagelayer_print($param); $el['atts']['post_html'] = pagelayer_posts($param); } // Author Box function pagelayer_sc_author_box(&$el){ global $post; if($el['atts']['box_source'] == 'current'){ $author_data = pagelayer_author_data ($post->ID); $el['atts']['display_name'] = $author_data['display_name']; $el['atts']['description'] = $author_data['description']; $el['atts']['user_url'] = $author_data['user_url']; $el['tmp']['avatar-url'] = $author_data['avatar']; $el['tmp']['avatar-title'] = ''; $el['tmp']['avatar-alt'] = ''; }else{ $el['tmp']['avatar-url'] = empty($el['tmp']['avatar-url']) ? $el['atts']['avatar'] : $el['tmp']['avatar-url']; } $el['atts']['display_html'] = '<'.$el['atts']['name_style'].'>'.$el['atts']['display_name'].'</'.$el['atts']['name_style'].'>'; } //Grid Gallery Handler function pagelayer_sc_login(&$el){ if(pagelayer_is_live()){ $el['atts']['login_cap'] = ''; return false; } ob_start(); if(!did_action( 'login_enqueue_scripts' )){ do_action( 'login_enqueue_scripts' ); } do_action( 'login_form' ); $el['atts']['login_cap'] = ob_get_clean(); } // Load all tags function pagelayer_get_tags(){ $tags = get_tags(['hide_empty' => false]); $taglist = array(); $taglist[] = 'Default'; foreach ($tags as $tag) { $taglist[$tag->name] = $tag->name ; } return $taglist; } // Load all categories function pagelayer_get_categories(){ $categories = get_categories(['hide_empty' => 0]); $category_list = array(); $category_list[] = 'Default'; foreach($categories as $category) { $category_list[$category->name] = $category->name ; } return $category_list; } // Templates Handler - 2C function pagelayer_sc_templates(&$el){ global $pagelayer, $post; if( !empty($el['atts']['templates']) ) $id = $el['atts']['templates']; $post_obj = get_post($id); $content = ''; // If both current post and tempate post are same if (empty( $post_obj) || (!empty( $post_obj) && $post_obj == $post) ) { $el['atts']['template_content'] = $content; return; } $pagelayer->dont_make_editable = true; $content = $post_obj->post_content; $content = apply_filters( 'the_content', $content ); $pagelayer->dont_make_editable = false; if(pagelayer_is_live()){ // Create the HTML object $node = pagelayerQuery::parseStr($content); $node->query('.pagelayer-ele')->removeClass('pagelayer-ele'); $content = $node->html(); } $el['atts']['template_content'] = $content; } // Get the list of post by post type - 2C function pagelayer_post_list_by_type($post_type = 'post'){ $postlist = []; $posts_list = get_posts(array( 'post_type' => $post_type, 'numberposts' => -1 )); foreach($posts_list as $post){ $postlist[$post->ID] = $post->post_title; } return $postlist; } ///////////////////////////////////// // WooCommerce Shortcode Functions ///////////////////////////////////// // Product Images Handler - 2C function pagelayer_sc_product_images(&$el){ global $product; $product = pagelayer_get_product(); $images_templ = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $images_templ = __pl('no_woo_product'); } if( empty( $product ) ) { $el['atts']['product_images_templ'] = $images_templ; return; } // Start the output buffer ob_start(); if( !empty($el['atts']['sale_flash']) ){ wc_get_template( 'loop/sale-flash.php' ); } wc_get_template( 'single-product/product-image.php' ); $el['atts']['product_images_templ'] = ob_get_clean(); } // Related products Handler - 2C function pagelayer_sc_product_related(&$el){ global $product; $product = pagelayer_get_product(); $related_templ = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $related_templ = __pl('no_woo_product'); } if( empty( $product ) ) { $el['atts']['related_products'] = $related_templ; return; } // start output buffer ob_start(); // If is related if($el['atts']['select_product'] == 'related'){ $args = [ 'posts_per_page' => 4, 'columns' => 4, 'orderby' => $el['atts']['order_by'], 'order' => $el['atts']['order'], ]; if( ! empty( $el['atts']['posts_per_page'] ) ) { $args['posts_per_page'] = $el['atts']['posts_per_page']; } if( ! empty( $el['atts']['columns'] ) ) { $args['columns'] = $el['atts']['columns']; } if(function_exists( 'woocommerce_related_products' )){ woocommerce_related_products($args); } // If is upsel; }elseif($el['atts']['select_product'] == 'upsell'){ $limit = '-1'; $columns = 4; $orderby = $el['atts']['order_by']; $order = $el['atts']['order']; if( ! empty( $el['atts']['columns'] ) ) { $columns = $el['atts']['columns']; } if(function_exists( 'woocommerce_upsell_display' )){ woocommerce_upsell_display( $limit, $columns, $orderby, $order ); } } // Get data and clean output buffer $el['atts']['related_products'] = ob_get_clean(); } // WooCommers Pages - 2C function pagelayer_sc_woo_pages(&$el){ // if is not empty if(!empty($el['atts']['pages'])){ $shortcode = '['. $el['atts']['pages'] .']'; $content = pagelayer_the_content($shortcode); // if is checkout page if ( 'woocommerce_checkout' === $el['atts']['pages'] && '<div class="woocommerce"></div>' == $content ) { $content = '<div class="woocommerce">' . __( 'Your cart is currently empty.') . '</div>'; } } // If the content is empty if(empty($content)){ $content = '<div class="woocommerce">' . __( 'Page content not found.') . '</div>'; } $el['atts']['page_content'] = $content; } // Product Pages - 2C function pagelayer_sc_product_categories(&$el){ $attributes = ''; $attributes .= ' number="'. (isset($el['atts']['number']) ? $el['atts']['number'] : '').'" '; $attributes .= ' columns="'. (isset($el['atts']['columns']) ? $el['atts']['columns'] : '').'" '; $attributes .= ' hide_empty="'. (!empty($el['atts']['hide_empty']) ? 1 : 0) .'" '; $attributes .= ' orderby="'. (isset($el['atts']['nuorderbymber']) ? $el['atts']['nuorderbymber'] : '') .'" '; $attributes .= ' order="'. (isset($el['atts']['order']) ? $el['atts']['order'] : '') .'" '; $source = isset($el['atts']['source']) ? $el['atts']['source'] : ''; if ( 'by_id' === $source ) { $attributes .= ' ids="'. $el['atts']['by_id'] .'" '; } elseif ( 'by_parent' === $source ) { $attributes .= ' parent="'. $el['atts']['parent'] .'" '; } elseif ( 'current_subcategories' === $source ) { $attributes .= ' parent="'. get_queried_object_id() .'" '; } $shortcode = '[product_categories '. $attributes .']'; // do_shortcode the shortcode $el['atts']['product_categories'] = pagelayer_the_content($shortcode); } // Products - 2C function pagelayer_sc_products(&$el){ if( WC()->session ){ wc_print_notices(); } $no_found = $el['atts']['no_found']; $attributes = ''; $type = $el['atts']['source']; $attributes .= ' columns="'. $el['atts']['columns'] .'" '; $attributes .= ' rows="'. $el['atts']['rows'] .'" '; $attributes .= ' paginate="'. (!empty($el['atts']['paginate']) ? true : false) .'" '; $attributes .= ' orderby="'. $el['atts']['orderby'] .'" '; $attributes .= ' order="'. $el['atts']['order'] .'" '; $attributes .= ' cache="false" '; // Hide the catalog order if( empty($el['atts']['allow_order']) ){ remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); } // Hide the result count if( empty($el['atts']['show_result']) ){ remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); } if( $type == 'by_id' ){ $type = 'products'; $attributes .= ' ids="'. (!empty($el['atts']['ids']) ? $el['atts']['ids'] : '') .'" '; }elseif( $type == 'pagelayer_current_query' ){ $atts['paginate'] = (!empty($el['atts']['paginate']) ? true : false); $atts['cache'] = false; $type = 'pagelayer_current_query'; // Set the current query add_action( 'woocommerce_shortcode_products_query', 'pagelayer_shortcode_current_query', 10, 10); // If product not found add_action( "woocommerce_shortcode_{$type}_loop_no_results", function ($attributes) use ($no_found){ echo '<div class="pagelayer-product-no-found">'.$no_found.'</div>'; } ); $shortcode = new WC_Shortcode_Products( $atts, $type ); $el['atts']['products_content'] = $shortcode->get_content(); return true; } $shortcode = '['.$type.' '. $attributes .']'; $content = pagelayer_the_content($shortcode); // If product not found if('<div class="woocommerce columns-'.$el['atts']['columns'] .' "></div>' == $content){ $content = '<div class="pagelayer-product-no-found">'. __($no_found) .'</div>'; } $el['atts']['products_content'] = $content; } // Archives Product Pages - 2C function pagelayer_sc_product_archives(&$el){ global $post; if ( WC()->session ) { wc_print_notices(); } $atts['paginate'] = true; $atts['cache'] = false; $no_found = $el['atts']['no_found']; if( empty($el['atts']['allow_order']) ){ remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); } if( empty($el['atts']['show_result']) ){ remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); } $type = 'pagelayer_current_query'; // We need to define costom if( (isset($post->post_type) && $post->post_type == 'pagelayer-template') || wp_doing_ajax()){ $type = ''; } // Set the current query add_action( 'woocommerce_shortcode_products_query', 'pagelayer_shortcode_current_query', 10, 10); // If product not found add_action( "woocommerce_shortcode_{$type}_loop_no_results", function ($attributes) use ($no_found){ echo '<div class="pagelayer-product-no-found">'.$no_found.'</div>'; } ); $shortcode = new WC_Shortcode_Products( $atts, $type ); $el['atts']['product_archives'] = $shortcode->get_content(); } // Product Price render - 2C function pagelayer_sc_product_price(&$el) { global $product; $product = pagelayer_get_product(); $price = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $price = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['pagelayer-product-price'] = $price; return; } ob_start(); wc_get_template( '/single-product/price.php' ); $el['atts']['pagelayer-product-price'] = ob_get_clean(); } // Product add to cart render - 2C function pagelayer_sc_add_to_cart(&$el) { global $product; $product = pagelayer_get_product(); $cart = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $cart = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['product_add_to_cart'] = $cart; return; } ob_start(); woocommerce_template_single_add_to_cart(); $el['atts']['product_add_to_cart'] = '<div class="pagelayer-add-to-cart-holder pagelayer-product-'. esc_attr( $product->get_type() ) .'"> '. ob_get_clean() .' </div>'; } // Product rating render - 2C function pagelayer_sc_product_rating(&$el) { if( ! post_type_supports( 'product', 'comments' ) ){ return; } global $product; $product = pagelayer_get_product(); $product_rating = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $product_rating = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['product_rating'] = $product_rating; return; } ob_start(); wc_get_template( '/single-product/rating.php' ); $product_rating = ob_get_clean(); if( empty( $product_rating ) && pagelayer_is_live_template()){ $product_rating = __('No Rating Found!'); } $el['atts']['product_rating'] = $product_rating; } /* // Product stock render - 2C function pagelayer_product_stock() { global $product; $product = wc_get_product(); if ( empty( $product ) ) { return; } return wc_get_stock_html( $product ); } */ // Product meta render - 2C function pagelayer_sc_product_meta(&$el) { global $product; $product = pagelayer_get_product(); $product_meta = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $product_meta = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['product_meta'] = $product_meta; return; } ob_start(); wc_get_template( '/single-product/meta.php' ); $el['atts']['product_meta'] = ob_get_clean(); } // Product short description render - 2C function pagelayer_sc_product_short_desc(&$el) { global $product, $post; $product = pagelayer_get_product(); $product_short_desc = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $product_short_desc = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['product_short_desc'] = $product_short_desc; return; } if((isset($post->post_type) && $post->post_type == 'pagelayer-template') || wp_doing_ajax()){ $el['atts']['product_short_desc'] = '<div class="woocommerce-product-details__short-description"><p>'.$product->get_short_description().'</p></div>'; return; } ob_start(); wc_get_template( 'single-product/short-description.php' ); $el['atts']['product_short_desc'] = ob_get_clean(); } // WooCommerce breadcrumb render - 2C function pagelayer_woo_breadcrumb() { ob_start(); woocommerce_breadcrumb(); return ob_get_clean(); } // Get product categories - 2C function pagelayer_get_product_cat() { $categories = get_terms( 'product_cat' ); $options = []; foreach ( $categories as $category ) { $options[ $category->term_id ] = $category->name; } return $options; } // Get product categories - 2C function pagelayer_get_product_archives_desc() { ob_start(); do_action( 'woocommerce_archive_description' ); return ob_get_clean(); } // Get product additional Information - 2C function pagelayer_sc_product_addi_info(&$el) { global $product; $product = pagelayer_get_product(); $product_additional_info = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $product_additional_info = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['product_additional_info'] = $product_additional_info; return; } ob_start(); wc_get_template( 'single-product/tabs/additional-information.php' ); $el['atts']['product_additional_info'] = ob_get_clean(); } // Get product data tab Information - 2C function pagelayer_sc_product_data_tabs(&$el) { global $product, $post; $product = pagelayer_get_product(); $product_data_tab = ''; if( empty( $product ) && (pagelayer_is_live_template() || wp_doing_ajax())){ $product_data_tab = __pl('no_woo_product'); } if ( empty( $product ) ) { $el['atts']['product_data_tab'] = $product_data_tab; return; } // We need load Pagelayer shortcodes pagelayer_load_shortcodes(); setup_postdata( $product->get_id()); ob_start(); wc_get_template( 'single-product/tabs/tabs.php' ); $data_tabs = ob_get_clean(); // If no data tabs if(empty($data_tabs)){ $data_tabs = __('Data tab not found'); } $el['atts']['product_data_tab'] = $data_tabs; } // Get the HTML for menu cart function pagelayer_sc_woo_menu_cart(&$el){ // Maybe init cart $has_cart = is_a( WC()->cart, 'WC_Cart' ); if ( ! $has_cart ) { $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' ); WC()->session = new $session_class(); WC()->session->init(); WC()->cart = new \WC_Cart(); WC()->customer = new \WC_Customer( get_current_user_id(), true ); } // Get the cart values $widget_cart_is_hidden = apply_filters( 'woocommerce_widget_cart_is_hidden', is_cart() || is_checkout() ); $product_count = WC()->cart->get_cart_contents_count(); $sub_total = WC()->cart->get_cart_subtotal(); $cart_items = WC()->cart->get_cart(); $toggle_button_link = $widget_cart_is_hidden ? wc_get_cart_url() : '#'; /** workaround WooCommerce Subscriptions issue that changes the behavior of is_cart() */ $toggle_button_classes = 'pagelayer-cart-button pagelayer-size-sm'; $toggle_button_classes .= $widget_cart_is_hidden ? ' pagelayer-menu-cart-hidden' : ''; $counter_attr = 'data-counter="' . $product_count . '"'; $cart_html = '<div class="pagelayer-menu-cart-toggle"> <a href="'. esc_attr( $toggle_button_link ) .'" class="'. $toggle_button_classes .'"> <span class="pagelayer-cart-button-text">'. $sub_total .'</span> <span class="pagelayer-cart-button-icon" '. $counter_attr .'> <i class="'.$el['atts']['icon_type'].'" aria-hidden="true"></i> </span> </a> </div>'; // If is cart and checkout page the except this if ( ! $widget_cart_is_hidden ){ ob_start(); wc_get_template( 'cart/mini-cart.php' ); $mini_cart_html = ob_get_clean(); $cart_html .= '<div class="pagelayer-menu-cart-container"> <form class="pagelayer-menu-cart-main woocommerce-cart-form" action="'. esc_url( wc_get_cart_url() ) .'" method="post"> <div class="pagelayer-menu-cart-close">×</div> '. $mini_cart_html .' </form> </div>'; } $el['atts']['cart_html'] = $cart_html; } // SiteMap Item Box - 2C function pagelayer_sc_sitemap_item(&$el){ $html_element = ''; $hier = ''; $depth = ''; $option = ''; $id = $el['id']; $option = '<div class="pagelayer-sitemap-section">'; $hier = (empty($el['atts']['hierarchical']) ? '' : $el['atts']['hierarchical']); $depth = (empty($el['atts']['depth']) ? '' : $el['atts']['depth']); if($el['atts']['sitemap_type'] == 'post_type'){ if(empty($el['atts']['title'])){ $el['atts']['title'] = 'Pages'; } $html_element .= $el['atts']['title']; $args = array( 'post_type' => $el['atts']['source_post'], 'orderby' => $el['atts']['order_post'], 'order' => $el['atts']['order'], 'hierarchical' => $hier, 'number' => $depth, 'posts_per_page' => -1, ); $option .= '<span>'.$html_element.'</span>'; $option .= '<ul>'; $pages = new WP_Query($args); $posts = $pages->posts; foreach ( $posts as $page ) { $option .= '<li class="pagelayer-sitemap-list-item" data-postID="'.$page->ID.'"><a class="pagelayer-ele-link" href="'.get_permalink($page->ID).'">'.$page->post_name.'</a></li>'; } $option .= '</ul>'; }else{ if(empty($el['atts']['title'])){ $el['atts']['title'] = 'Categories'; } $html_element .= $el['atts']['title']; $args = array( 'title_li' => 0, 'orderby' => $el['atts']['order_taxonomy'], 'order' => $el['atts']['order'], 'style' => '', 'hide_empty' => $el['atts']['hide_empty'], 'echo' => false, 'hierarchical' => $hier, 'taxonomy' => $el['atts']['source_taxonomy'], 'depth' => $depth, ); $taxonomies = get_categories( $args ); $option .= '<span>'.$html_element.'</span>'; $option .= '<ul>'; foreach ( $taxonomies as $taxonomy ) { $option .= '<li class="pagelayer-sitemap-list-item" data-postID="'.$taxonomy->term_id.'"><a class="pagelayer-ele-link" href="'.get_term_link($taxonomy->term_id).'">'.$taxonomy->name.'</a></li>'; } $option .= '</ul>'; } $option .= '</div>'; $el['atts']['sitemap_html'] = $option; } function pagelayer_sc_slides(&$el) { if( !pagelayer_is_live() ) { return; } foreach($el['inner_blocks'] as $key => $inner_block) { if(empty($inner_block['blockName']) || 'pagelayer/pl_slide' != $inner_block['blockName']) { continue; } $slide = serialize_block($inner_block); $col = get_comment_delimited_block_content('pagelayer/pl_col', [] , $slide); $row = get_comment_delimited_block_content('pagelayer/pl_inner_row', ['col_gap' => '0.0'] , $col); $el['inner_blocks'][$key] = array( 'blockName' => 'pagelayer/pl_content_slide', 'innerBlocks' => parse_blocks($row), 'innerHTML' => '', 'attrs' => array(), 'innerContent' => array(), ); } } function pagelayer_sc_chart(&$el){ $el['atts']['xcolor'] = empty($el['atts']['xcolor']) ? '' : pagelayer_parse_color($el['atts']['xcolor'], false); $el['atts']['ycolor'] = empty($el['atts']['ycolor']) ? '' : pagelayer_parse_color($el['atts']['ycolor'], false); } function pagelayer_sc_chart_datasets(&$el){ $el['atts']['chart_border_color'] = empty($el['atts']['chart_border_color']) ? '' : pagelayer_parse_color($el['atts']['chart_border_color'], false); $el['atts']['bg_color'] = empty($el['atts']['bg_color']) ? '' : pagelayer_parse_color($el['atts']['bg_color'], false); } // Render the image map function pagelayer_sc_image_map(&$el) { $map_size = pagelayer_isset($el['atts'], 'img_map-size'); $map_key = 'img_map-id-' . $map_size . '-url'; $el['atts']['map_img_id'] = isset($el['tmp'][$map_key]) ? $el['tmp'][$map_key] : pagelayer_isset($el['tmp'], 'map_img-id-url'); $el['atts']['pagelayer-srcset'] = $el['atts']['map_img_id'] . ', ' . $el['atts']['map_img_id'] . ' 1x, '; // Handle multiple paths if(isset($el['atts']['pagelayer_image_map']) && is_array($el['atts']['pagelayer_image_map'])){ $el['atts']['pagelayer_map_path'] = ''; // Initialize as empty foreach ($el['atts']['pagelayer_image_map'] as $key => $data) { $data_cord = isset($data['path']) ? $data['path'] : ''; $data_id = isset($key) ? $key : ''; $data_link = isset($data['link']) ? $data['link'] : ''; $el['atts']['pagelayer_map_path'] .= "<path class='pagelayer-imgmap-item' d='' stroke-width='2' data-cord='" . $data_cord . "' data-id='" . $data_id . "' fill-opacity='0.3' fill-rule='evenodd' data-link='" . $data_link . "'></path>"; } } if(empty($el['atts']['pagelayer_map_path'])){ $el['atts']['pagelayer_map_path'] = ' '; } $image_atts = array( 'name' => 'img_map-id', 'size' => 'img_map-size' ); pagelayer_get_img_srcset($el, $image_atts); }PK !fh[yt8�g<