/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $button_defaults = array('name' => '', 'price_string' => '', 'price_currency_iso' => '', 'custom' => '', 'description' => '', 'type' => 'buy_now', 'style' => 'buy_now_large'); $button_args = array(); foreach ($instance as $k => $v) { if ($k != 'size' && $k != 'title') { $button_args[$k] = $v; } } $size = $instance['size']; $style = $instance['type'] . '_' . $size; $button_args['style'] = $style; $transient_name = 'cb_ecc_' . md5(serialize($button_args)); $cached = get_transient($transient_name); if ($cached !== false) { // Cached echo $cached; } else { $api_key = wpsf_get_setting('coinbase', 'general', 'api_key'); $api_secret = wpsf_get_setting('coinbase', 'general', 'api_secret'); if ($api_key && $api_secret) { try { $coinbase = Coinbase::withApiKey($api_key, $api_secret); $button = $coinbase->createButtonWithOptions($button_args)->embedHtml; } catch (Exception $e) { $msg = $e->getMessage(); error_log($msg); echo "There was an error connecting to Coinbase: {$msg}. Please check your internet connection and API credentials."; } set_transient($transient_name, $button); echo $button; } else { echo "The Coinbase plugin has not been properly set up - please visit the Coinbase settings page in your administrator console."; } } echo $after_widget; }
function coinbase_content_filter($content) { $autoembed_enable = wpsf_get_setting('coinbase', 'autoembed', 'enable'); $autoembed_type = wpsf_get_setting('coinbase', 'autoembed', 'type'); $userinfo = wpsf_get_setting('coinbase', 'general', 'userinfo'); if (is_single()) { if ($autoembed_enable == 1) { // autoembed is enabled, so lets output it.. if ($autoembed_type == 'top') { $content = $this->create_coinbase_button($userinfo) . $content; } else { if ($autoembed_type == 'bottom') { $content = $content . $this->create_coinbase_button($userinfo); } else { if ($autoembed_type == 'top_bottom') { $content = $this->create_coinbase_button($userinfo) . $content . $this->create_coinbase_button($userinfo); } else { $content = $content; } } } } } return $content; }
static function desc() { if ('1' == wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'advanced', 'memtest')) { return sprintf('Use this link to test your actual server ram. <a href="%s">CLICK HERE TO TEST NOW</a><br /><kbd>DO NOT LEAVE THIS ENABLED!!!</kbd>', add_query_arg(array('pl_memcheck' => 1), admin_url())); } else { return '<p>Most cheap hosts although they say 256M of RAM is allocated to your account in reality it is limited in other ways.<br />This simple test will reveal your true account limitations.</p>'; } }
function advanced_search_query($where) { if (is_search() && '1' === wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'search', 'enabled')) { global $wpdb; $query = get_search_query(); $query = like_escape($query); // include postmeta in search $where .= " OR {$wpdb->posts}.ID IN (SELECT {$wpdb->postmeta}.post_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->postmeta}.meta_key = 'pl-settings' AND {$wpdb->postmeta}.meta_value LIKE '%{$query}%' AND {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)"; // include taxonomy in search $where .= " OR {$wpdb->posts}.ID IN (SELECT {$wpdb->posts}.ID FROM {$wpdb->posts},{$wpdb->term_relationships},{$wpdb->terms} WHERE {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id AND {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->terms}.term_id AND {$wpdb->terms}.name LIKE '%{$query}%')"; } return $where; }
public function init() { $this->uploads_only = apply_filters('wp_stack_cdn_uploads_only', defined('WP_STACK_CDN_UPLOADS_ONLY') ? WP_STACK_CDN_UPLOADS_ONLY : false); $this->extensions = apply_filters('wp_stack_cdn_extensions', array('jpe?g', 'gif', 'png', 'css', 'bmp', 'js', 'ico')); if (!is_admin()) { $this->hook('template_redirect'); if ($this->uploads_only) { $this->hook('wp_stack_cdn_content', 'filter_uploads_only'); } else { $this->hook('wp_stack_cdn_content', 'filter'); } $this->site_domain = parse_url(get_bloginfo('url'), PHP_URL_HOST); $this->cdn_domain = defined('WP_STACK_CDN_DOMAIN') ? WP_STACK_CDN_DOMAIN : wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'cdn', 'cdn-enabled'); } }
static function cache_stats() { if (!is_admin()) { return; } if ('1' == wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'section_cache', 'cache-enabled')) { global $wpdb; $threshold = time() - 60; // count transient expiration records, total and expired $sql = "select count(*) as `total`, count(case when option_value < '{$threshold}' then 1 end) as `expired`\n\t\t\t\t\tfrom {$wpdb->options}\n\t\t\t\t\twhere (option_name like '\\_transient\\_timeout\\_section\\_cache\\_%')"; $counts = $wpdb->get_row($sql); $query = $wpdb->get_row($sql); $expired = $query->expired; $count = $query->total; // delete expired transients, using the paired timeout record to find them $sql = "\n\t\t\t\t\t\tdelete from t1, t2\n\t\t\t\t\t\tusing {$wpdb->options} t1\n\t\t\t\t\t\tjoin {$wpdb->options} t2 on t2.option_name = replace(t1.option_name, '_timeout', '')\n\t\t\t\t\t\twhere (t1.option_name like '\\_transient\\_timeout\\_section\\_cache%')\n\t\t\t\t\t\tand t1.option_value < '{$threshold}';\n\t\t\t\t\t"; $wpdb->query($sql); $out = sprintf('<br /><strong>%s</strong> total cached sections found.<br /><strong>%s</strong> stale sections were detected and deleted from the db.', $count, $expired); return $out; } }
static function cache_stats() { if ('1' == wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'section_cache', 'cache-enabled')) { global $wpdb; $stale = 0; $where = "option_name LIKE '\\_transient_section_cache%'"; $transients = $wpdb->get_col("SELECT option_name FROM {$wpdb->options} WHERE {$where}"); $count = count($transients); $cache_key = self::pl_get_cache_key(); foreach ($transients as $k => $name) { $key = str_replace('_transient_section_cache_', '', $name); $key = explode('_', $key); if ($key[0] != $cache_key) { $stale++; delete_transient(str_replace('_transient_', '', $name)); } } $out = sprintf('<br /><strong>%s</strong> total cache sections found.<br /><strong>%s</strong> stale sections were detected and deleted from the db.', $count, $stale); return $out; } }
function add_js() { if (!wp_script_is('cookiejs', 'queue')) { wp_enqueue_script('cookiejs', plugins_url(basename(__DIR__) . '/js/cookie.min.js'), array('jquery')); } wp_enqueue_script('check', plugins_url(basename(__DIR__) . '/js/check.js'), array('jquery')); wp_localize_script('check', 'check', array('ajaxurl' => admin_url('admin-ajax.php'))); $param = wpsf_get_setting(wpsf_get_option_group(plugin_dir_path(__FILE__) . 'php/settings.php'), 'ppc', 'param'); wp_localize_script('check', 'get', $param); }
function bulk() { if ('1' === wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'bulk_edit', 'enabled')) { new PL_Bulk_edit(); } }
function lazyload() { if ('1' === wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'lazyload', 'enabled')) { new LazyLoad_Images_Pro(); } }
function advanced_search_query($where) { if (!defined('CORE_VERSION') || version_compare(CORE_VERSION, '2.1', '<')) { return $where; } if (is_search() && '1' === wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'search', 'enabled')) { global $wpdb; $query = get_search_query(); $query = like_escape($query); $result = $this->search_sections($query); $where .= " OR {$wpdb->posts}.ID IN ( '{$result}' )"; } return $where; }
function shortcode($atts, $content = null) { $defaults = array('name' => 'test', 'price_string' => '1.23', 'price_currency_iso' => 'USD', 'custom' => 'Order123', 'description' => 'Sample description', 'type' => 'buy_now', 'style' => 'buy_now_large', 'text' => 'Pay with Bitcoin', 'choose_price' => false, 'variable_price' => false, 'price1' => '0.0', 'price2' => '0.0', 'price3' => '0.0', 'price4' => '0.0', 'price5' => '0.0'); $args = shortcode_atts($defaults, $atts, 'coinbase_button'); // Clear default price suggestions for ($i = 1; $i <= 5; $i++) { if ($args["price{$i}"] == '0.0') { unset($args["price{$i}"]); } } $transient_name = 'cb_ecc_' . md5(serialize($args)); $cached = get_transient($transient_name); if ($cached !== false) { return $cached; } $api_key = wpsf_get_setting('coinbase', 'general', 'api_key'); $api_secret = wpsf_get_setting('coinbase', 'general', 'api_secret'); if ($api_key && $api_secret) { try { $coinbase = Coinbase::withApiKey($api_key, $api_secret); $button = $coinbase->createButtonWithOptions($args)->embedHtml; } catch (Exception $e) { $msg = $e->getMessage(); error_log($msg); return "There was an error connecting to Coinbase: {$msg}. Please check your internet connection and API credentials."; } set_transient($transient_name, $button); return $button; } else { return "The Coinbase plugin has not been properly set up - please visit the Coinbase settings page in your administrator console."; } }