public function is_aop() { return !empty($this->p->options['plugin_tid']) && self::$a && class_exists('SucomUpdate') && ($u = SucomUpdate::get_umsg($this->p->cf['lca']) ? self::$n : self::$a) ? $u : self::$n; }
public function aop($lca = '', $active = true) { $lca = empty($lca) ? $this->p->cf['lca'] : $lca; $uca = strtoupper($lca); $installed = defined($uca . '_PLUGINDIR') && is_dir(constant($uca . '_PLUGINDIR') . 'lib/pro/') ? true : false; return $active === true ? !empty($this->p->options['plugin_' . $lca . '_tid']) && $installed && class_exists('SucomUpdate') && ($umsg = SucomUpdate::get_umsg($lca) ? false : $installed) ? $umsg : false : $installed; }
public function show_admin_notices() { $hidden = array(); $msg_html = ''; $nag_msgs = ''; $all_opts = $this->get_all_options(); $all_msgs = array(); $have_changes = false; $user_id = get_current_user_id(); $dis_arr = empty($user_id) ? false : get_user_option($this->dis_name, $user_id); // get dismissed message ids if (isset($this->p->cf['plugin']) && class_exists('SucomUpdate')) { foreach (array_keys($this->p->cf['plugin']) as $lca) { if (!empty($this->p->options['plugin_' . $lca . '_tid'])) { $umsg = SucomUpdate::get_umsg($lca); if ($umsg !== false && $umsg !== true) { $all_opts['log']['err'][$umsg] = array(); } } } } foreach (array('opt', 'usr', 'log') as $name) { foreach (array_keys($this->log) as $type) { foreach ($all_opts[$name][$type] as $msg_txt => $payload) { if (empty($msg_txt) || isset($all_msgs[$msg_txt])) { continue; } $all_msgs[$msg_txt] = true; // avoid duplicates switch ($type) { case 'nag': $nag_msgs .= $msg_txt; // append to echo a single message continue; default: if (!empty($payload['dismiss']) && isset($dis_arr[$payload['msg_id']])) { $now_time = time(); $dis_time = $dis_arr[$payload['msg_id']]; if (empty($dis_time) || $dis_time > $now_time) { $payload['hidden'] = true; if (isset($hidden[$type])) { $hidden[$type]++; } else { $hidden[$type] = 1; } } else { $have_changes = true; unset($dis_arr[$payload['msg_id']]); } } $msg_html .= $this->get_notice_html($type, $msg_txt, $payload); break; } } } } $this->trunc(); // don't save unless we've changes something if ($have_changes === true && !empty($user_id)) { if (empty($dis_arr)) { delete_user_option($user_id, $this->dis_name); } else { update_user_option($user_id, $this->dis_name, $dis_arr); } } echo "\n"; echo '<!-- ' . $this->lca . ' admin notices begin -->' . "\n"; if (!empty($nag_msgs)) { echo $this->get_nag_style(); echo $this->get_notice_html('nag', $nag_msgs); } // remind the user that there are hidden warning messages if (isset($hidden['err'])) { if ($hidden['err'] > 1) { echo $this->get_notice_html('inf', sprintf(__('%1$d warning messages have been hidden — <a id="%2$s">unhide these notices temporarily</a>.', $this->text_dom), $hidden['err'], $this->lca . '-unhide-notices')); } elseif ($hidden['err'] > 0) { echo $this->get_notice_html('inf', sprintf(__('%1$d warning message has been hidden — <a id="%2$s">unhide this notice temporarily</a>.', $this->text_dom), $hidden['err'], $this->lca . '-unhide-notices')); } } echo $msg_html; echo '<!-- ' . $this->lca . ' admin notices end -->' . "\n"; }
public function aop($lca = '', $lic = true, $rv = true) { $lca = empty($lca) ? $this->p->cf['lca'] : $lca; $kn = $lca . '-' . $lic . '-' . $rv; if (isset(self::$c[$kn])) { return self::$c[$kn]; } $uca = strtoupper($lca); if (defined($uca . '_PLUGINDIR')) { $pdir = constant($uca . '_PLUGINDIR'); } elseif (isset($this->p->cf['plugin'][$lca]['slug'])) { $slug = $this->p->cf['plugin'][$lca]['slug']; if (!defined('WPMU_PLUGIN_DIR') || !is_dir($pdir = WPMU_PLUGIN_DIR . '/' . $slug . '/')) { if (!defined('WP_PLUGIN_DIR') || !is_dir($pdir = WP_PLUGIN_DIR . '/' . $slug . '/')) { return self::$c[$kn] = false; } } } else { return self::$c[$kn] = false; } $on = 'plugin_' . $lca . '_tid'; $ins = is_dir($pdir . 'lib/pro/') ? $rv : false; return self::$c[$kn] = $lic === true ? !empty($this->p->options[$on]) && $ins && class_exists('SucomUpdate') && ($um = SucomUpdate::get_umsg($lca) ? false : $ins) ? $um : false : $ins; }
public function set_objects($activate = false) { /* * basic plugin setup (settings, check, debug, notices, utils) */ $this->set_options(); require_once NGFB_PLUGINDIR . 'lib/com/debug.php'; if (!empty($this->options['plugin_tid'])) { require_once NGFB_PLUGINDIR . 'lib/com/update.php'; } $this->check = new NgfbCheck($this); $this->is_avail = $this->check->get_avail(); // uses options if ($this->is_avail['aop']) { $this->cf['full'] = $this->cf['full_pro']; } // load and config debug class $html_debug = !empty($this->options['plugin_debug']) || defined('NGFB_HTML_DEBUG') && NGFB_HTML_DEBUG ? true : false; $wp_debug = defined('NGFB_WP_DEBUG') && NGFB_WP_DEBUG ? true : false; if ($html_debug || $wp_debug) { $this->debug = new SucomDebug($this, array('html' => $html_debug, 'wp' => $wp_debug)); } else { $this->debug = new NgfbNoDebug(); } $this->notice = new SucomNotice($this); $this->util = new NgfbUtil($this); $this->opt = new NgfbOptions($this); $this->cache = new SucomCache($this); // object and file caching $this->style = new SucomStyle($this); // admin styles $this->script = new SucomScript($this); // admin jquery tooltips $this->webpage = new SucomWebpage($this); // title, desc, etc., plus shortcodes $this->user = new NgfbUser($this); // contact methods and metabox prefs $this->media = new NgfbMedia($this); // images, videos, etc. $this->head = new NgfbHead($this); // open graph and twitter card meta tags if (is_admin()) { $this->msgs = new NgfbMessages($this); // admin tooltip messages $this->admin = new NgfbAdmin($this); // admin menus and page loader } if ($this->is_avail['opengraph']) { $this->og = new NgfbOpengraph($this); } else { $this->og = new SucomOpengraph($this); } // read open graph html tags if ($this->is_avail['ssb']) { $this->sharing = new NgfbSharing($this); } // wp_head and wp_footer js and buttons if (!$this->check->is_aop() || get_option($this->cf['lca'] . '_umsg') || SucomUpdate::get_umsg($this->cf['lca'])) { require_once NGFB_PLUGINDIR . 'lib/gpl/addon.php'; $this->gpl = new NgfbAddonGpl($this); } else { $this->pro = new NgfbAddonPro($this); } do_action($this->cf['lca'] . '_init_addon'); /* * check and create the default options array * * execute after all objects have been defines, so hooks into 'ngfb_get_defaults' are available */ if (is_multisite() && (!is_array($this->site_options) || empty($this->site_options))) { $this->site_options = $this->opt->get_site_defaults(); } if ($activate == true || !empty($_GET['action']) && $_GET['action'] == 'activate-plugin' && !empty($_GET['plugin']) && $_GET['plugin'] == NGFB_PLUGINBASE) { $this->debug->log('plugin activation detected'); if (!is_array($this->options) || empty($this->options) || defined('NGFB_RESET_ON_ACTIVATE') && NGFB_RESET_ON_ACTIVATE) { $this->options = $this->opt->get_defaults(); delete_option(NGFB_OPTIONS_NAME); add_option(NGFB_OPTIONS_NAME, $this->options, null, 'yes'); $this->debug->log('default options have been added to the database'); } $this->debug->log('exiting early: init_plugin() to follow'); return; // no need to continue, init_plugin() will handle the rest } /* * check and upgrade options if necessary */ $this->options = $this->opt->check_options(NGFB_OPTIONS_NAME, $this->options); if (is_multisite()) { $this->site_options = $this->opt->check_options(NGFB_SITE_OPTIONS_NAME, $this->site_options); } /* * configure class properties based on plugin settings */ $this->cache->object_expire = $this->options['plugin_object_cache_exp']; if (!empty($this->options['plugin_file_cache_hrs'])) { if ($this->debug->is_on('wp') === true) { $this->cache->file_expire = NGFB_DEBUG_FILE_EXP; } else { $this->cache->file_expire = $this->options['plugin_file_cache_hrs'] * 60 * 60; } } else { $this->cache->file_expire = 0; } // just in case $this->is_avail['cache']['file'] = $this->cache->file_expire > 0 ? true : false; // disable the transient and object cache ONLY if the html debug mode is on if ($this->debug->is_on('html') === true) { foreach (array('object', 'transient') as $name) { $constant_name = 'NGFB_' . strtoupper($name) . '_CACHE_DISABLE'; $this->is_avail['cache'][$name] = defined($constant_name) && !constant($constant_name) ? true : false; } $cache_msg = 'object cache ' . ($this->is_avail['cache']['object'] ? 'could not be' : 'is') . ' disabled, and transient cache ' . ($this->is_avail['cache']['transient'] ? 'could not be' : 'is') . ' disabled.'; $this->debug->log('HTML debug mode active: ' . $cache_msg); $this->notice->inf('HTML debug mode active – ' . $cache_msg . ' ' . __('Informational messages are being added to webpages as hidden HTML comments.', NGFB_TEXTDOM)); } // setup the update checks if we have an Authentication ID if (!empty($this->options['plugin_tid'])) { add_filter($this->cf['lca'] . '_ua_plugin', array(&$this, 'filter_ua_plugin'), 10, 1); add_filter($this->cf['lca'] . '_installed_version', array(&$this, 'filter_installed_version'), 10, 1); $this->update = new SucomUpdate($this, $this->cf['lca'], $this->cf['slug'], NGFB_PLUGINBASE, $this->cf['url']['pro_update']); if (is_admin()) { // if update_hours * 2 has passed without an update, then force one now $last_update = get_option($this->cf['lca'] . '_utime'); if (empty($last_update) || !empty($this->cf['update_hours']) && $last_update + $this->cf['update_hours'] * 7200 < time()) { $this->update->check_for_updates(); } } } }
public function admin_notices() { $all_nag_msgs = ''; foreach (array_keys($this->log) as $type) { $user_id = get_current_user_id(); // since wp 3.0 $msg_opt = $this->lca . '_notices_' . $type; $msg_arr = array_unique(array_merge((array) get_option($msg_opt), (array) get_user_option($msg_opt, $user_id), $this->log[$type])); $this->trunc($type); if ($type === 'err' && isset($this->p->cf['plugin']) && class_exists('SucomUpdate')) { foreach (array_keys($this->p->cf['plugin']) as $lca) { if (!empty($this->p->options['plugin_' . $lca . '_tid'])) { $umsg = SucomUpdate::get_umsg($lca); if ($umsg !== false && $umsg !== true) { $msg_arr[] = $umsg; } } } } if (!empty($msg_arr)) { if ($type == 'nag') { echo $this->get_nag_style($this->lca); } foreach ($msg_arr as $key => $msg) { if (!empty($msg)) { $label = ''; $class = ''; $cssid_attr = strpos($key, $type . '_') === 0 ? ' id="' . $key . '"' : ''; switch ($type) { case 'nag': $all_nag_msgs .= $msg; // append to echo later in single div block break; case 'err': if (empty($class)) { $class = 'error'; } if (empty($label) && !empty($this->label)) { $label = $this->label . ' Notice'; } // or 'Warning' // no break // or 'Warning' // no break case 'inf': // allow for variable definitions in previous case blocks if (empty($class)) { $class = 'updated fade'; } if (empty($label) && !empty($this->label)) { $label = $this->label . ' Notice'; } // or 'Info' echo '<div class="' . $class . '"' . $cssid_attr . '>'; if (!empty($label)) { echo '<div style="display:table-cell;"> <p style="margin:5px 0;white-space:nowrap;"> <b>' . $label . '</b>:</p></div>'; } echo '<div style="display:table-cell;"> <p style="margin:5px;text-align:left">' . $msg . '</p></div>'; echo '</div>'; break; } } } } } if (!empty($all_nag_msgs)) { echo '<div class="update-nag ' . $this->lca . '-update-nag">', $all_nag_msgs, '</div>', "\n"; } }
public function admin_notices() { $all_nag_msgs = ''; foreach (array('nag', 'err', 'inf') as $type) { $user_id = get_current_user_id(); // since wp 3.0 $msg_opt = $this->lca . '_notices_' . $type; $msg_arr = array_unique(array_merge((array) get_option($msg_opt), (array) get_user_option($msg_opt, $user_id), $this->log[$type])); $this->trunc($type); if ($type === 'err' && class_exists('SucomUpdate')) { foreach ($this->p->cf['plugin'] as $lca => $info) { if (($umsg = SucomUpdate::get_umsg($lca)) !== false && $umsg !== true) { $msg_arr[] = $umsg; } } } if (!empty($msg_arr)) { if ($type == 'nag') { echo '<style type="text/css"> .' . $this->lca . '-update-nag { display:block; line-height:1.4em; background-image: url("' . constant($this->p->cf['uca'] . '_URLPATH') . 'images/background.jpg"); background-position:top; background-size:cover; border:1px dashed #ccc; padding:10px 40px 10px 40px; margin-top:0; } .' . $this->lca . '-update-nag p, .' . $this->lca . '-update-nag ul { max-width:900px; margin:15px auto 15px auto; text-align:center; } .' . $this->lca . '-update-nag li { list-style:circle outside none; text-align:left; margin:5px 0 5px 20px; } </style>'; } foreach ($msg_arr as $key => $msg) { if (!empty($msg)) { $cssid = strpos($key, $type . '_') === 0 ? $cssid = ' id="' . $key . '"' : ''; switch ($type) { case 'nag': $all_nag_msgs .= $msg; break; case 'err': echo '<div class="error"' . $cssid . '><div style="float:left;"><p style="white-space:nowrap;"><b>' . $this->p->cf['menu'] . ' Warning</b> :</p></div> <p style="text-align:left">' . $msg . '</p></div>' . "\n"; break; case 'inf': echo '<div class="updated fade"' . $cssid . '><div style="float:left;"><p style="white-space:nowrap;"><b>' . $this->p->cf['menu'] . ' Info</b> :</p></div> <p style="text-align:left">' . $msg . '</p></div>' . "\n"; break; } } } } } if (!empty($all_nag_msgs)) { echo '<div class="update-nag ' . $this->lca . '-update-nag">', $all_nag_msgs, '</div>', "\n"; } }