/** * Tracking logic * * @since 1.0.0 */ public function tracker() { if (is_admin() || $this->is_bot()) { return; } $request = $this->getRequestString(); $id = url_to_postid($request); if ($id > 0 && !$this->disableTracking) { $this->setAsVisited($id); } if ($this->isRefLocal(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')) { $parsedReq = $this->parseSearchQuery($request); if (isset($parsedReq['erp_from']) && $id > 0) { $this->db->addClick((int) $parsedReq['erp_from'], $id); } } }
/** * Return an instance of this class. * * @since 1.0.0 * @return object A single instance of this class. */ public static function getInstance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
private function getCachedRatings($pid) { return $this->dbActions->getAllOccurrences($pid); }
/** * 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); }
/** * 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; }
/** * 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')); }