public static function getHTML($url, $atts = array()) { $args = gPluginUtils::recursiveParseArgs($atts, array('timeout' => 15)); $response = wp_remote_get($url, $args); if (!self::isError($response) && 200 == wp_remote_retrieve_response_code($response)) { return wp_remote_retrieve_body($response); } return FALSE; }
public function setup_globals($constants = array(), $args = array()) { $this->args = gPluginUtils::recursiveParseArgs($args, array('domain' => 'gplugin', 'title' => 'gPlugin', 'filter_prefix' => FALSE)); if (FALSE === $this->args['filter_prefix']) { $this->inject('args', array('filter_prefix' => $this->args['domain'])); } $this->constants = gPluginUtils::recursiveParseArgs($constants, array('plugin_dir' => GPLUGIN_DIR, 'plugin_url' => GPLUGIN_URL)); $this->filtered = array(); }
public function setup_globals($constants = array(), $args = array()) { $this->args = gPluginUtils::recursiveParseArgs($args, array('title' => 'gPlugin', 'domain' => 'gplugin', 'network' => TRUE, 'options' => array())); $this->constants = apply_filters($this->args['domain'] . '_network_constants', $constants); $this->current_blog = get_current_blog_id(); // $this->blog_map = get_site_option( $this->args['domain'].'_blog_map', array() ); // FIXME $this->root = FALSE; $this->remote = FALSE; if (isset($this->constants['class_filters'])) { gPluginFactory::get($this->constants['class_filters'], $constants, $args); } }
public static function getUsers($all_fields = FALSE, $network = FALSE) { $users = get_users(array('blog_id' => $network ? '' : $GLOBALS['blog_id'], 'orderby' => 'display_name', 'fields' => $all_fields ? 'all_with_meta' : 'all')); return gPluginUtils::reKey($users, 'ID'); }
public function locate_template($template_names, $load = FALSE, $require_once = TRUE) { $located = FALSE; $dir = '/' . $this->constants['theme_templates_dir'] . '/'; foreach ((array) $template_names as $template_name) { if (empty($template_name)) { continue; } $name = gPluginUtils::untrail($template_name); if (file_exists(get_stylesheet_directory() . $dir . $name)) { $located = get_stylesheet_directory() . $dir . $name; } else { if (file_exists(get_template_directory() . $dir . $name)) { $located = get_template_directory() . $dir . $name; } else { if (file_exists($this->constants['plugin_dir'] . '/templates/' . $name)) { $located = $this->constants['plugin_dir'] . '/templates/' . $name; } } } if ($located) { break; } } if ($load && !empty($located)) { load_template($located, $require_once); } return $located; }
public static function reKey($list, $key) { self::__dep('gPluginUtils::reKey()'); return gPluginUtils::reKey($list, $key); }
public function setup_globals($constants = array(), $args = array()) { $this->args = gPluginUtils::recursiveParseArgs($args, array('domain' => 'gplugin', 'title' => 'gPlugin', 'logger_args' => array('name' => 'Logs', 'post_type' => 'gplugin_log', 'taxonomy' => 'gplugin_log_type', 'meta_prefix' => '_gplugin_log_', 'hook_prefix' => 'gplugin_log_', 'types' => array('error', 'event')))); $this->constants = gPluginUtils::recursiveParseArgs($constants, array('plugin_dir' => GPLUGIN_DIR, 'plugin_url' => GPLUGIN_URL)); }
public function settings_sanitize_section($sections, $input, $output, $stored = array()) { foreach ($sections as $section => $section_args) { foreach ($section_args['fields'] as $field => $field_args) { if (isset($field_args['constant']) && $field_args['constant'] && defined($field_args['constant'])) { // do nothing // new value } else { if (isset($input[$field])) { // callback if (isset($field_args['filter']) && $field_args['filter'] && is_callable($field_args['filter'])) { $output[$field] = call_user_func_array($field_args['filter'], array($input[$field])); } else { if (isset($field_args['values']) && FALSE === $field_args['values']) { $output[$field] = $field_args['default']; } else { if (is_array($input[$field])) { $output[$field] = gPluginUtils::getKeys($input[$field]); } else { $output[$field] = $input[$field]; } } } // empty multiple checkboxes } else { if (isset($field_args['values']) && FALSE !== $field_args['values']) { $output[$field] = array(); // custom multiple checkboxes } else { if (in_array($field_args['type'], array('posttypes'))) { $output[$field] = array(); // previously stored value } else { if (isset($stored[$field])) { $output[$field] = $stored[$field]; // default value } else { $output[$field] = $field_args['default']; } } } } } } } return $output; }