/** * Add filters to each Achievements option and allow them to be overloaded * from inside the achievements()->options array. * * @since Achievements (3.0) */ function dpa_setup_option_filters() { // Add filters to each option foreach (array_keys(dpa_get_default_options()) as $key) { add_filter('pre_option_' . $key, 'dpa_pre_get_option'); } // Let other plugins add their own option filters do_action('dpa_setup_option_filters'); }
/** * Add filters to each Achievements option and allow them to be overloaded * from inside the $achievements->options array. * * @since 3.0 */ function dpa_setup_option_filters() { $options = dpa_get_default_options(); // Add filters to each option foreach ($options as $key => $value) { add_filter('pre_option_' . $key, 'dpa_pre_get_option'); } // Run an action for other plugins do_action('dpa_setup_option_filters'); }
/** * Set up global variables * * @since Achievements (3.0) */ private function setup_globals() { // Versions $this->version = '3.5.1'; $this->db_version = 340; // Paths - plugin $this->file = __FILE__; $this->basename = apply_filters('dpa_basename', str_replace(array('build/', 'src/'), '', plugin_basename($this->file))); $this->plugin_dir = apply_filters('dpa_plugin_dir_path', plugin_dir_path($this->file)); $this->plugin_url = apply_filters('dpa_plugin_dir_url', plugin_dir_url($this->file)); // Paths - theme compatibility packs $this->themes_dir = apply_filters('dpa_themes_dir', trailingslashit($this->plugin_dir . 'templates')); $this->themes_url = apply_filters('dpa_themes_url', trailingslashit($this->plugin_url . 'templates')); // Paths - languages $this->lang_dir = apply_filters('dpa_lang_dir', trailingslashit($this->plugin_dir . 'languages')); // Includes $this->includes_dir = apply_filters('dpa_includes_dir', trailingslashit($this->plugin_dir . 'includes')); $this->includes_url = apply_filters('dpa_includes_url', trailingslashit($this->plugin_url . 'includes')); // Post type/endpoint/taxonomy identifiers $this->achievement_post_type = apply_filters('dpa_achievement_post_type', 'achievement'); $this->achievement_progress_post_type = apply_filters('dpa_achievement_progress_post_type', 'dpa_progress'); $this->authors_endpoint = apply_filters('dpa_authors_endpoint', 'achievements'); $this->event_tax_id = apply_filters('dpa_event_tax_id', 'dpa_event'); // Post status identifiers $this->locked_status_id = apply_filters('dpa_locked_post_status', 'dpa_locked'); $this->unlocked_status_id = apply_filters('dpa_unlocked_post_status', 'dpa_unlocked'); // Queries $this->current_achievement_id = 0; // Current achievement ID $this->achievement_query = new WP_Query(); // Main achievement post type query $this->leaderboard_query = new ArrayObject(); // Leaderboard template loop $this->progress_query = new WP_Query(); // Main dpa_progress post type query // Theme compat $this->theme_compat = new stdClass(); // Base theme compatibility class $this->filters = new stdClass(); // Used when adding/removing filters // Other stuff $this->domain = 'achievements'; // Unique identifier for retrieving translated strings $this->errors = new WP_Error(); // Errors $this->extensions = new stdClass(); // Other plugins add data here // Deep integration with other plugins $this->integrate_into_buddypress = false; // Use BuddyPress profiles for screens like "my achievements" /** * If multisite and running network-wide, grab the options from the site options * table and store in achievements()->options. dpa_setup_option_filters() sets * up a pre_option filter which loads from achievements()->options if an option * has been set there. This saves a lot of conditionals throughout the plugin. */ if (is_multisite() && dpa_is_running_networkwide()) { $options = dpa_get_default_options(); foreach ($options as $option_name => $option_value) { achievements()->options[$option_name] = get_site_option($option_name); } } }