/** * 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(); }
/** * Handle Process Jobs bulk action * * @param array<string> $ids * @param PodsUI $obj */ public static function admin_page_process_jobs($ids, $obj) { self::admin_page_process_jobs_ajax($ids); $obj->action_bulk = false; unset($_GET['action_bulk']); $obj->bulk = array(); unset($_GET['action_bulk_ids']); $obj->manage(); }