/** * * @param array $options * @author Panagiotis Vagenas <*****@*****.**> * @since 1.0.0 */ protected function __construct($options) { if (!class_exists('erpPROQueryFormater')) { erpPROPaths::requireOnce(erpPROPaths::$erpPROQueryFormater); } if (!class_exists('erpPRODBActions')) { erpPROPaths::requireOnce(erpPROPaths::$erpPRODBActions); } if (!class_exists('erpPRORatingSystem')) { erpPROPaths::requireOnce(erpPROPaths::$erpPRORatingSystem); } if (!class_exists('erpPRORelData')) { erpPROPaths::requireOnce(erpPROPaths::$erpPRORelData); } $this->options = $options; $this->dbActions = erpPRODBActions::getInstance(); $this->wpSession = WP_Session::get_instance(); }
/** * This is for a future release. * It should be called through ajax and rebuild cache for all posts in that are cached * * @author Panagiotis Vagenas <*****@*****.**> * @since 1.0.0 */ public function rebuildCache() { if (!user_can_access_admin_page() || !current_user_can('manage_options')) { echo json_encode(false); die; } // This may take a while so set time limit to 0 set_time_limit(0); erpPROPaths::requireOnce(erpPROPaths::$erpPRODBActions); erpPROPaths::requireOnce(erpPROPaths::$erpPROMainOpts); erpPROPaths::requireOnce(erpPROPaths::$erpProRelated); $db = erpPRODBActions::getInstance(); $mainOpts = new erpPROMainOpts(); $rel = erpProRelated::get_instance($mainOpts); $allCached = $db->getUniqueIds(); $db->emptyRelTable(); $plugin = easyRelatedPostsPRO::get_instance(); global $wpdb, $wp_actions; foreach ($allCached as $key => $value) { $pid = (int) $value['pid']; if ($plugin->isInExcludedPostTypes($pid) || $plugin->isInExcludedTaxonomies($pid)) { continue; } $rel->doRating($pid); } echo json_encode(true); die; }
/** * Increases displayed values for given pids * * @param int $pid * @param array $pids * @author Panagiotis Vagenas <*****@*****.**> * @since 1.0.0 */ public static function addDisplayed($pid, array $pids) { erpPROPaths::requireOnce(erpPROPaths::$erpPRODBActions); $db = erpPRODBActions::getInstance(); $db->addDisplayed($pid, $pids); }
/** * Initialize the plugin by setting localization and loading public scripts * and styles. * * @since 1.0.0 */ private function __construct() { // Dependencies erpPROPaths::requireOnce(erpPROPaths::$erpPRODBActions); erpPROPaths::requireOnce(erpPROPaths::$erpPROMainOpts); erpPROPaths::requireOnce(erpPROPaths::$erpPROWidOpts); erpPROPaths::requireOnce(erpPROPaths::$erpPROTracker); $this->wpSession = WP_Session::get_instance(); $this->DB = erpPRODBActions::getInstance(); $this->mainOpts = new erpPROMainOpts(); $this->widOpts = new erpPROWidOpts(); /** * Check if rating system is on in order to call tracker */ $tracker = new erpPROTracker($this->DB, $this->wpSession, $this->mainOpts->getDisableTrackingSystem()); add_action('init', array($tracker, 'tracker')); /** * Call content modifier */ add_filter('the_content', array($this, 'contentFilter'), 1000); // Load plugin text domain add_action('init', array($this, 'load_plugin_textdomain')); // Activate plugin when new blog is added add_action('wpmu_new_blog', array($this, 'activate_new_site')); // Load public-facing style sheet and JavaScript. add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); }