RCCWP_Options::Get PHP Méthode

Get() public static méthode

if is not specified a key is return a array with all the options of magic fields
public static Get ( string $key = null )
$key string is the name of the option.
    public static function Get($key = null)
    {
        if (get_option(RC_CWP_OPTION_KEY) == "") {
            return "";
        }
        if (is_array(get_option(RC_CWP_OPTION_KEY))) {
            $options = get_option(RC_CWP_OPTION_KEY);
        } else {
            $options = unserialize(get_option(RC_CWP_OPTION_KEY));
        }
        if (!empty($key)) {
            if (isset($options[$key])) {
                return $options[$key];
            }
            return false;
        } else {
            return $options;
        }
    }

Usage Example

Exemple #1
0
 /**
  *  Filter all the posts in POST -> Edit  for doesn't display 
  *  the posts created using some write panel.
  */
 public static function ExcludeWritepanelsPosts($where)
 {
     global $wpdb, $parent_file;
     $types = array('edit.php', 'edit-pages.php', 'edit.php?post_type=page');
     if (!in_array($parent_file, $types)) {
         return $where;
     }
     require_once 'RCCWP_Options.php';
     $exclude = RCCWP_Options::Get('hide-non-standart-content');
     if ($exclude == false) {
         return $where;
     }
     if (empty($_GET['filter-posts'])) {
         $where = $where . " AND 0 = (SELECT count({$wpdb->postmeta}.meta_value) FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID and {$wpdb->postmeta}.meta_key = '_mf_write_panel_id')";
     }
     //is search
     if (isset($_GET['s']) && isset($_GET['filter-posts'])) {
         $remove = "/and wp_postmeta.meta_key = '_mf_write_panel_id' and wp_postmeta.meta_value = '(\\w)'/";
         $where = preg_replace($remove, "", $where);
         $sql = $wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = '%s'", array("_mf_write_panel_id", $_GET['custom-write-panel-id']));
         $results = $wpdb->get_results($sql);
         if (count($results) == 0) {
             return $where;
         }
         $postIDs = array();
         foreach ($results as $result) {
             $postIDs[] = $result->post_id;
         }
         if (count($postIDs) == 1) {
             $postIDs[] = $postIDs[0];
         }
         $where .= sprintf(" AND {$wpdb->posts}.ID IN (%s)", implode(",", $postIDs));
     }
     return $where;
 }
All Usage Examples Of RCCWP_Options::Get
RCCWP_Options