/** * Clear Pod-related cache * * @param array $pod * * @return void * * @since 2.0 */ public function cache_flush_pods($pod = null) { /** * @var $wpdb wpdb */ global $wpdb; pods_transient_clear('pods'); pods_transient_clear('pods_components'); if (null !== $pod && is_array($pod)) { pods_transient_clear('pods_pod_' . $pod['name']); pods_cache_clear($pod['name'], 'pods-class'); foreach ($pod['fields'] as $field) { pods_transient_clear('pods_field_' . $pod['name'] . '_' . $field['name']); } if (in_array($pod['type'], array('post_type', 'taxonomy'))) { pods_transient_clear('pods_wp_cpt_ct'); } } else { pods_transient_clear('pods_wp_cpt_ct'); } $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_pods%'"); $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_timeout_pods%'"); pods_cache_clear(true); pods_transient_set('pods_flush_rewrites', 1); }
/** * Load activated components and init component * * @since 2.0 */ public function load() { do_action('pods_components_load'); foreach ((array) $this->components as $component => $component_data) { $component_data['MustUse'] = apply_filters('pods_component_require_' . $component_data['ID'], $component_data['MustUse'], $component_data); if (false === $component_data['MustUse'] && (!isset($this->settings['components'][$component]) || 0 == $this->settings['components'][$component])) { continue; } if (!empty($component_data['PluginDependency'])) { $dependency = explode('|', $component_data['PluginDependency']); if (!pods_is_plugin_active($dependency[1])) { continue; } } if (!empty($component_data['ThemeDependency'])) { $dependency = explode('|', $component_data['ThemeDependency']); if (strtolower($dependency[1]) != strtolower(get_template()) && strtolower($dependency[1]) != strtolower(get_stylesheet())) { continue; } } if (false === $component_data['External']) { $component_data['File'] = realpath($this->components_dir . $component_data['File']); } if (empty($component_data['File'])) { pods_transient_clear('pods_components'); continue; } if (!file_exists($component_data['File'])) { pods_message('Pods Component not found: ' . $component_data['File']); pods_transient_clear('pods_components'); continue; } include_once $component_data['File']; if (!empty($component_data['Class']) && class_exists($component_data['Class']) || isset($component_data['object'])) { if (!isset($this->components[$component]['object'])) { $this->components[$component]['object'] = new $component_data['Class'](); } if (method_exists($this->components[$component]['object'], 'options')) { if (isset($this->settings['components'][$component])) { $this->components[$component]['options'] = $this->components[$component]['object']->options($this->settings['components'][$component]); } else { $this->components[$component]['options'] = $this->components[$component]['object']->options(array()); } $this->options($component, $this->components[$component]['options']); } else { $this->options($component, array()); } if (method_exists($this->components[$component]['object'], 'handler')) { $this->components[$component]['object']->handler($this->settings['components'][$component]); } } } }
/** * Toggle a component on or off * * @param PodsUI $ui * * @return bool */ public function admin_components_toggle(PodsUI $ui) { $component = $_GET['id']; if (!empty(PodsInit::$components->components[$component]['PluginDependency'])) { $dependency = explode('|', PodsInit::$components->components[$component]['PluginDependency']); if (!pods_is_plugin_active($dependency[1])) { $website = 'http://wordpress.org/extend/plugins/' . dirname($dependency[1]) . '/'; if (isset($dependency[2])) { $website = $dependency[2]; } if (!empty($website)) { $website = ' ' . sprintf(__('You can find it at %s', 'pods'), '<a href="' . $website . '" target="_blank">' . $website . '</a>'); } $message = sprintf(__('The %s component requires that you have the <strong>%s</strong> plugin installed and activated.', 'pods'), PodsInit::$components->components[$component]['Name'], $dependency[0]) . $website; $ui->error($message); $ui->manage(); return; } } if (!empty(PodsInit::$components->components[$component]['ThemeDependency'])) { $dependency = explode('|', PodsInit::$components->components[$component]['ThemeDependency']); if (strtolower($dependency[1]) != strtolower(get_template()) && strtolower($dependency[1]) != strtolower(get_stylesheet())) { $website = ''; if (isset($dependency[2])) { $website = ' ' . sprintf(__('You can find it at %s', 'pods'), '<a href="' . $dependency[2] . '" target="_blank">' . $dependency[2] . '</a>'); } $message = sprintf(__('The %s component requires that you have the <strong>%s</strong> theme installed and activated.', 'pods'), PodsInit::$components->components[$component]['Name'], $dependency[0]) . $website; $ui->error($message); $ui->manage(); return; } } if (!empty(PodsInit::$components->components[$component]['MustUse'])) { $message = sprintf(__('The %s component can not be disabled from here. You must deactivate the plugin or theme that added it.', 'pods'), PodsInit::$components->components[$component]['Name']); $ui->error($message); $ui->manage(); return; } if (1 == pods_var('toggled')) { $toggle = PodsInit::$components->toggle($component); if (true === $toggle) { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component enabled', 'pods')); } elseif (false === $toggle) { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component disabled', 'pods')); } $components = PodsInit::$components->components; foreach ($components as $component => &$component_data) { $toggle = 0; if (isset(PodsInit::$components->settings['components'][$component_data['ID']])) { if (0 != PodsInit::$components->settings['components'][$component_data['ID']]) { $toggle = 1; } } if (true === $component_data['DeveloperMode']) { if (!pods_developer()) { unset($components[$component]); continue; } } $component_data = array('id' => $component_data['ID'], 'name' => $component_data['Name'], 'description' => make_clickable($component_data['Description']), 'version' => $component_data['Version'], 'author' => $component_data['Author'], 'toggle' => $toggle); } $ui->data = $components; pods_transient_clear('pods_components'); $url = pods_var_update(array('toggled' => null)); pods_redirect($url); } elseif (1 == pods_var('toggle')) { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component enabled', 'pods')); } else { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component disabled', 'pods')); } $ui->manage(); }
/** * Clear cache on save * * @since 2.0 */ public function clear_cache($data, $pod = null, $id = null, $groups = null, $post = null) { $old_post = $id; if (!is_object($id)) { $old_post = null; } if (is_object($post) && $this->object_type != $post->post_type) { return; } if (!is_array($data) && 0 < $data) { $post = $data; $post = get_post($post); } if ($this->object_type == $post->post_type) { pods_transient_clear('pods_object_pages'); if (is_object($old_post) && $this->object_type == $old_post->post_type) { pods_cache_clear($old_post->post_title, 'pods_object_page_wildcard'); } pods_cache_clear($post->post_title, 'pods_object_page_wildcard'); self::flush_rewrites(); } }
/** * @param null $_blog_id */ public function reset($_blog_id = null) { global $wpdb; // Switch DB table prefixes if (null !== $_blog_id && $_blog_id != $wpdb->blogid) { switch_to_blog(pods_absint($_blog_id)); } else { $_blog_id = null; } $api = pods_api(); $pods = $api->load_pods(array('names_ids' => true)); foreach ($pods as $pod_id => $pod_label) { $api->delete_pod(array('id' => $pod_id)); } $templates = $api->load_templates(); foreach ($templates as $template) { $api->delete_template(array('id' => $template['id'])); } $pages = $api->load_pages(); foreach ($pages as $page) { $api->delete_page(array('id' => $page['id'])); } $helpers = $api->load_helpers(); foreach ($helpers as $helper) { $api->delete_helper(array('id' => $helper['id'])); } $tables = $wpdb->get_results("SHOW TABLES LIKE '{$wpdb->prefix}pods%'", ARRAY_N); if (!empty($tables)) { foreach ($tables as $table) { $table = $table[0]; pods_query("DROP TABLE `{$table}`", false); } } // Remove any orphans $wpdb->query("\n DELETE `p`, `pm`\n FROM `{$wpdb->posts}` AS `p`\n LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n ON `pm`.`post_id` = `p`.`ID`\n WHERE\n `p`.`post_type` LIKE '_pods_%'\n "); delete_option('pods_framework_version'); delete_option('pods_framework_db_version'); delete_option('pods_framework_upgrade_2_0'); delete_option('pods_framework_upgraded_1_x'); // @todo Make sure all entries are being cleaned and do something about the pods_framework_upgrade_{version} dynamic entries created by PodsUpgrade delete_option('pods_framework_upgrade_2_0_0'); delete_option('pods_framework_upgrade_2_0_sister_ids'); delete_option('pods_framework_version_last'); delete_option('pods_component_settings'); $api->cache_flush_pods(); pods_transient_clear('pods_flush_rewrites'); self::$version = ''; // Restore DB table prefix (if switched) if (null !== $_blog_id) { restore_current_blog(); } }
/** * Delete transients that stores the settings. * * @since 2.5.5 */ function reseter() { $keys = array('pods_pfat_the_pods', 'pods_pfat_auto_pods', 'pods_pfat_archive_test'); foreach ($keys as $key) { pods_transient_clear($key); } }
/** * Clear cache on save * * @since 2.0 */ public function clear_cache($data, $pod = null, $id = null, $groups = null, $post = null) { $old_post = $id; if (!is_object($id)) { $old_post = null; } if (is_object($post) && $this->object_type != $post->post_type) { return; } if (!is_array($data) && 0 < $data) { $post = $data; $post = get_post($post); } if ($this->object_type == $post->object_type) { pods_transient_clear('pods_object_helpers'); } }