/** * Retrieves a unique array of all published Singulars, protected with Specific Post/Page Access. * * @package s2Member\Utilities * @since 111101 * * @uses {@link http://codex.wordpress.org/Function_Reference/get_posts get_posts()} * * @param bool $exclude_conflicts Optional. Defaults to false. If true, return ONLY those which are NOT in conflict with any other Restriction Types. * The ``$exclude_conflicts`` argument should be used whenever we introduce a list of option values to a site owner. Helping them avoid mishaps. * Please note, the ``$exclude_conflicts`` argument implements a resource-intensive processing routine. * @return array Unique array of all Singulars *(i.e. Posts/Pages )* protected with Specific Post/Page Access. * Includes Custom Post Types also, as specified by site owner's Specific Post/Page Restrictions. */ public static function get_all_singulars_with_sp($exclude_conflicts = FALSE) { $singulars = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && is_array($singulars = get_posts("post_status=publish&post_type=any&include=" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) ? $singulars : array(); if (!empty($singulars) && is_array($singulars) && $exclude_conflicts) { $all_singular_ids_not_conflicting = c_ws_plugin__s2member_utils_gets::get_all_singular_ids_with_sp("exclude-conflicts"); foreach ($singulars as $s => $singular) { if (!in_array($singular->ID, $all_singular_ids_not_conflicting)) { unset($singulars[$s]); } } } return !empty($singulars) && is_array($singulars) ? c_ws_plugin__s2member_utils_arrays::array_unique($singulars) : array(); }
/** * Retrieves a unique array of all published Singulars, protected with Specific Post/Page Access. * * @package s2Member\Utilities * @since 111101 * * @uses {@link http://codex.wordpress.org/Function_Reference/get_posts get_posts()} * * @param bool $exclude_conflicts Optional. Defaults to false. If true, return ONLY those which are NOT in conflict with any other Restriction Types. * The ``$exclude_conflicts`` argument should be used whenever we introduce a list of option values to a site owner. Helping them avoid mishaps. * Please note, the ``$exclude_conflicts`` argument implements a resource-intensive processing routine. * * @return array Unique array of all Singulars *(i.e., Posts/Pages )* protected with Specific Post/Page Access. * Includes Custom Post Types also, as specified by site owner's Specific Post/Page Restrictions. */ public static function get_all_singulars_with_sp($exclude_conflicts = FALSE) { $singulars = $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'] && is_array($singulars = get_posts('post_status=publish&post_type=any&include=' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'])) ? $singulars : array(); if (!empty($singulars) && is_array($singulars) && $exclude_conflicts) { $all_singular_ids_not_conflicting = c_ws_plugin__s2member_utils_gets::get_all_singular_ids_with_sp('exclude-conflicts'); foreach ($singulars as $s => $singular) { // Weed out anything that's in conflict here. if (!in_array($singular->ID, $all_singular_ids_not_conflicting)) { unset($singulars[$s]); } } // Housekeeping. } return !empty($singulars) && is_array($singulars) ? c_ws_plugin__s2member_utils_arrays::array_unique($singulars) : array(); }