Exemple #1
0
 /**
  * Filters ``$cwhere`` query portion.
  *
  * @package optimizeMember\Queries
  * @since 110912
  *
  * @attaches-to ``add_filter("comment_feed_where");``
  *
  * @param str $cwhere Expects the SQL `WHERE` portion to be passed through by the Filter.
  * @param obj $wp_query Expects ``$wp_query`` by reference, from the Filter.
  * @return str The revised ``$cwhere`` string.
  */
 public static function _query_level_access_coms($cwhere = FALSE, &$wp_query = FALSE)
 {
     global $wpdb;
     /* Need this global DB object reference here. */
     /**/
     if (is_string($cwhere) && is_object($wpdb) && is_object($wp_query) && !$wp_query->get("suppress_filters")) {
         $x_terms = array_merge((array) $wp_query->get("category__not_in"), (array) $wp_query->get("tag__not_in"));
         $x_terms = array_unique(c_ws_plugin__optimizemember_utils_arrays::force_integers($x_terms));
         $x_singulars = c_ws_plugin__optimizemember_utils_gets::get_singular_ids_in_terms($x_terms);
         /**/
         $cwhere .= " AND `" . $wpdb->comments . "`.`comment_post_ID` NOT IN('" . implode("','", (array) $wp_query->get("post__not_in")) . "')";
         $cwhere .= " AND `" . $wpdb->comments . "`.`comment_post_ID` NOT IN('" . implode("','", $x_singulars) . "')";
     }
     remove_filter("comment_feed_where", "c_ws_plugin__optimizemember_querys::_query_level_access_coms", 100, 2);
     return apply_filters("_ws_plugin__optimizemember_query_level_access_coms", $cwhere, get_defined_vars());
 }
Exemple #2
0
 /**
  * Retrieves a unique array of Singular IDs in the database, within specific term IDs.
  *
  * Only returns Singular IDs that are within the ``$terms`` passed through this function.
  *
  * @package optimizeMember\Utilities
  * @since 110912
  *
  * @param array $terms Required. An array of term IDs.
  * @return array Unique array of all Singular IDs *( as integers )* within the ``$terms`` passed through this function.
  */
 public static function get_singular_ids_in_terms($terms = FALSE)
 {
     global $wpdb;
     /* Need this global DB object reference here. */
     /**/
     if (!empty($terms) && is_array($terms) && is_array($singular_ids = $wpdb->get_col("SELECT `object_id` FROM `" . $wpdb->term_relationships . "` WHERE `term_taxonomy_id` IN (SELECT `term_taxonomy_id` FROM `" . $wpdb->term_taxonomy . "` WHERE `term_id` IN('" . implode("','", $terms) . "'))"))) {
         $singular_ids = c_ws_plugin__optimizemember_utils_arrays::force_integers($singular_ids);
     }
     /**/
     return !empty($singular_ids) && is_array($singular_ids) ? array_unique($singular_ids) : array();
 }
 /**
  * Forces integer values on each array value *( also supports multi-dimensional arrays )*.
  *
  * @package optimizeMember\Utilities
  * @since 111101
  *
  * @param array $array An input array.
  * @return array Returns the ``$array`` after having forced it to set of integer values.
  */
 public static function force_integers($array = FALSE)
 {
     $array = (array) $array;
     /**/
     foreach ($array as &$value) {
         if (is_array($value)) {
             $value = c_ws_plugin__optimizemember_utils_arrays::force_integers($value);
         } else {
             if (!is_integer($value)) {
                 $value = (int) $value;
             }
         }
     }
     return $array;
 }