/** * @internal */ public function wp_verify_nonce($action) { $nonce = FW_Request::GET('_wpnonce'); return $nonce && wp_verify_nonce($nonce, $action); }
/** * @intenral */ public function _action_calendar_export() { global $post; if (empty($post) or $post->post_type !== $this->post_type_name) { return; } if (FW_Request::GET('calendar')) { $calendar = FW_Request::GET('calendar'); $row_id = FW_Request::GET('row_id'); $offset = FW_Request::GET('offset'); $options = fw_get_db_post_option($post->ID, $this->get_event_option_id()); if (!is_array(fw_akg('event_children/' . $row_id, $options)) or !preg_match('/^\\d+$/', $row_id)) { wp_redirect(site_url() . '?error=404'); } if (!preg_match('/^(\\-|\\d)\\d+$/', $offset)) { $offset = 0; } switch ($calendar) { case 'google': wp_redirect($this->get_google_uri($post, $options, $row_id, $offset)); break; default: $this->get_ics_headers($post); echo $this->get_ics_content($post, $options, $row_id, $offset); die; } } }
private function display_extension_page() { // note: static is enqueued in 'admin_enqueue_scripts' action $extension_name = trim(FW_Request::GET('extension', '')); $installed_extensions = $this->get_installed_extensions(); $flash_id = 'fw_extension_page'; $error = ''; do { if (empty($extension_name)) { $error = __('Extension not specified.', 'fw'); break; } if (!isset($installed_extensions[$extension_name])) { $error = sprintf(__('Extension "%s" is not installed.', 'fw'), $this->get_extension_title($extension_name)); break; } } while (false); if ($error) { FW_Flash_Messages::add($flash_id, $error, 'error'); $this->js_redirect(); return; } $tab = fw_akg('tab', $_GET, 'settings'); if (!in_array($tab, array('settings', 'docs'))) { $tab = 'settings'; } $extension_title = $this->get_extension_title($extension_name); $link = $this->get_link(); echo '<div class="wrap" id="fw-extension-page">'; fw_render_view(dirname(__FILE__) . '/views/extension-page-header.php', array('extension_name' => $extension_name, 'extension_data' => $installed_extensions[$extension_name], 'link_delete' => $link . '&sub-page=delete', 'link_extension' => $link . '&sub-page=extension', 'extension_title' => $extension_title, 'tab' => $tab, 'is_supported' => fw()->theme->manifest->get('supported_extensions/' . $extension_name, false) !== false || $installed_extensions[$extension_name]['is']['theme']), false); unset($installed_extensions); echo '<div id="fw-extension-tab-content">'; $method_data = array(); switch ($tab) { case 'settings': $error = $this->display_extension_settings_page($extension_name, $method_data); break; case 'docs': $error = $this->display_extension_docs_page($extension_name, $method_data); break; } echo '</div>'; echo '</div>'; if ($error) { FW_Flash_Messages::add($flash_id, $error, 'error'); $this->js_redirect(); return; } }
/** * If now is a submit of this form * @return bool */ public function is_submitted() { if (is_null($this->is_submitted)) { $method = strtoupper($this->attr('method')); if ($method === 'POST') { $this->is_submitted = isset($_POST[self::$id_input_name]) && FW_Request::POST(self::$id_input_name) === $this->id; } elseif ($method === 'GET') { $this->is_submitted = isset($_GET[self::$id_input_name]) && FW_Request::GET(self::$id_input_name) === $this->id; } else { $this->is_submitted = false; } } return $this->is_submitted; }
/** * @internal * * @param WP_Query $query * * @return WP_Query */ public function _filter_admin_filter_portfolios_by_portfolio_category($query) { $screen = fw_current_screen_match(array('only' => array('base' => 'edit', 'id' => 'edit-' . $this->post_type, 'post_type' => $this->post_type))); if (!$screen || !$query->is_main_query()) { return $query; } $filter_value = FW_Request::GET($this->get_name() . '-filter-by-portfolio-category'); if (empty($filter_value)) { return $query; } $filter_value = (int) $filter_value; $query->set('tax_query', array(array('taxonomy' => $this->taxonomy_name, 'field' => 'id', 'terms' => $filter_value))); return $query; }
<?php echo fw()->backend->render_options($options, $values); ?> <div class="form-footer-buttons"> <!-- This div is required to follow after options in order to have special styles in case options will contain tabs (css adjacent selector + ) --> <?php echo fw_html_tag('input', array('type' => 'submit', 'name' => '_fw_save_options', 'value' => __('Save Changes', 'fw'), 'class' => 'button-primary button-large')); echo $side_tabs ? '' : ' '; echo fw_html_tag('input', array('type' => 'submit', 'name' => '_fw_reset_options', 'value' => __('Reset Options', 'fw'), 'class' => 'button-secondary button-large')); ?> </div> <!-- focus tab --> <?php $focus_tab_id = trim(FW_Request::POST($focus_tab_input_name, FW_Request::GET($focus_tab_input_name, ''))); echo fw_html_tag('input', array('type' => 'hidden', 'name' => $focus_tab_input_name, 'value' => $focus_tab_id)); ?> <script type="text/javascript"> jQuery(function($){ fwEvents.one("fw:options:init", function(){ var $form = $('form[data-fw-form-id="fw_settings"]:first'); $form.on("click", ".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a", function(){ $form.find("input[name='<?php echo esc_js($focus_tab_input_name); ?> ']").val( $(this).attr("href").replace(/^#/, "") // tab id ); });
/** * Generate translation columns. * * @param $columns * @param $post_type * * @return array */ public function generate_translation_columns($columns, $post_type) { if (!$this->is_public_post_type()) { return $columns; } $languages = is_null(FW_Request::GET('fw_all_languages')) ? $this->get_parent()->get_enabled_languages_without($this->get_parent()->get_admin_active_language()) : $this->get_parent()->get_enabled_languages(); $collector = array(); foreach ($languages as $code => $lang) { $collector['fw_lang_' . $code] = '<img src="' . fw_ext_translation_get_flag($code) . '" >'; } $col_copy = $columns; return array_merge(array_splice($columns, 0, 2), $collector, array_splice($col_copy, 2)); }
$post_type = get_post_type_object($backup->post_type()->get_post_type()); $active = array(); $inactive = array(); $backup_now = array(); foreach ($backup->cron()->get_cron_job_list() as $cron_job) { if ($cron_job->is_active()) { $active[] = $cron_job; } else { $inactive[] = $cron_job; } if ($cron_job->get_backup_now()) { $backup_now[] = $cron_job; } } $http_loopback_warning = false; if (!FW_Request::GET('feedback') && (!defined('ALTERNATE_WP_CRON') || !ALTERNATE_WP_CRON)) { $http_loopback_connection = fw_ext_backup_loopback_test(); if (!$http_loopback_connection['success']) { $http_loopback_warning = $http_loopback_connection['data']['message']; } } ?> <p class="backup-subtitle description" id="backup-subtitle"><?php _e('Here you can create a backup schedule for your website.', 'fw'); ?> </p> <div id="backup-container">
/** * Generate admin bar language switcher * * @param $wp_admin_bar */ function admin_language_switcher($wp_admin_bar) { global $pagenow; global $post; $parent_id = 'fw_language_switcher'; $active_lang = $this->get_admin_active_language(); $enabled_languages = $this->get_enabled_languages(); switch ($pagenow) { case 'post.php': case 'post-new.php': $post_id = $post->ID; $admin_switch_urls = $this->get_child('translate-posts')->generate_backend_switch_urls($post_id); break; case 'edit-tags.php': $term_id = FW_Request::GET('fw_translate_id', FW_Request::GET('tag_ID')); if (!is_null($term_id)) { $admin_switch_urls = $this->get_child('translate-terms')->generate_backend_switch_urls($term_id); } else { $admin_switch_urls = $this->generate_default_backend_switch_urls(); } break; case 'nav-menus.php': global $nav_menu_selected_id; $menu_id = FW_Request::GET('menu', $nav_menu_selected_id); $admin_switch_urls = $this->get_child('translate-menus')->generate_backend_switch_urls($menu_id); break; default: $admin_switch_urls = $this->generate_default_backend_switch_urls(); } $args = array('id' => $parent_id, 'title' => '<span style="cursor:pointer" ><img src="' . fw_ext_translation_get_flag($active_lang) . '"> ' . $enabled_languages[$active_lang]['name'] . '</span>', 'parent' => false); $wp_admin_bar->add_node($args); foreach ($admin_switch_urls as $key => $language) { $args = array('id' => 'fw-lang-' . $key, 'title' => '<img src="' . fw_ext_translation_get_flag($key) . '"> ' . $language['lang_name'], 'parent' => $parent_id, 'href' => $language['url']); $wp_admin_bar->add_node($args); } }
/** * Generate backend switch urls. * * @param $term_id * * @return array */ public function generate_backend_switch_urls($term_id, $all_languages = false) { $urls = array(); $meta_translation_id = fw_get_term_meta($term_id, 'translation_id', true); $translate_id = $meta_translation_id === '' ? $term_id : $meta_translation_id; $translate_lang = fw_get_term_meta($term_id, 'translation_lang', true) === '' ? $this->get_parent()->get_admin_active_language() : fw_get_term_meta($term_id, 'translation_lang', true); $taxonomy = FW_Request::GET('taxonomy', FW_Request::POST('taxonomy')); $translated_terms = $this->query_translation($translate_id); $translation_languages = $all_languages === true ? $this->get_parent()->get_enabled_languages() : $this->get_parent()->get_enabled_languages_without($translate_lang); $tax = get_taxonomy($taxonomy); $post_type = reset($tax->object_type); foreach ($translation_languages as $code => $language) { $translation_exists = $this->translation_exists($translated_terms, $code); if (empty($translation_exists)) { if ($meta_translation_id > 0) { $urls[$code] = array('lang_name' => $language['name'], 'url' => esc_url(add_query_arg(array('post_type' => $post_type, 'taxonomy' => $taxonomy, 'fw_translate_to' => $code, 'fw_translate_id' => $translate_id), admin_url('edit-tags.php'))), 'type' => 'add'); } else { $urls[$code] = array('lang_name' => $language['name'], 'url' => esc_url(add_query_arg(array('post_type' => $post_type, 'taxonomy' => $taxonomy, 'fw_translate_to' => $code, 'fw_translate_id' => $translate_id, 'fw_second_translate_to' => $this->get_parent()->get_admin_active_language()), admin_url('edit-tags.php'))), 'type' => 'add'); } } else { $urls[$code] = array('lang_name' => $language['name'], 'url' => get_edit_term_link($translation_exists['term_id'], $taxonomy), 'type' => 'edit'); } } return $urls; }
} ?> <div class="backup-controls"> <a href="#" data-action="backup-settings" data-options="<?php echo esc_attr(json_encode($backup->get_backup_settings_options())); ?> " data-values="<?php echo esc_attr(json_encode($backup->get_backup_settings_values())); ?> " class="button button-primary">Edit Backup Schedule</a> <?php if ($backup->wp_verify_nonce('backup-progress')) { ?> <a href="<?php echo esc_attr($backup->url_backup_cancel(FW_Request::GET('post'))); ?> ">Cancel</a> <?php } else { ?> <?php foreach ($backup_now as $cron) { ?> <a href="<?php echo esc_attr($backup->url_backup_now($cron->get_id())); ?> " class="button" data-action="backup-now">Create <?php echo esc_html($cron->get_title()); ?> Now</a>
/** * Update term meta, set term meta active lang. * * @param $term_id * @param $tt_id * @param $taxonomy */ function create_term($term_id, $tt_id, $taxonomy) { global $pagenow; if ('nav-menus.php' === $pagenow) { $language = FW_Request::GET('fw_translate_to', $this->get_parent()->get_admin_active_language()); $translation_id = FW_Request::GET('fw_translate_id', $term_id); fw_update_term_meta($term_id, 'translation_id', $translation_id); fw_update_term_meta($term_id, 'translation_lang', $language); } }
/** * @internal */ public function _admin_action_admin_init() { $nonce = FW_Request::REQUEST('_wpnonce'); // Auto-Install // Is a part of process of getting rid of update notifications after auto-install if (isset($_GET['auto-install-redirect'])) { wp_redirect($_GET['auto-install-redirect']); } // Auto Install (a process of restoring from **demo install** archive) if (wp_verify_nonce($nonce, 'backup-auto-install')) { $this->do_backup_auto_install(); } // Feedback if ($post_id = $this->get_feedback_subject()) { if (!$this->backup()->get_feedback($post_id)) { wp_redirect($this->url_backup_page()); exit; } } // Backup if (wp_verify_nonce($nonce, 'backup-now')) { $this->do_backup_now(FW_Request::GET('cron')); } if (wp_verify_nonce($nonce, 'backup-cancel')) { $this->do_backup_cancel(FW_Request::GET('post')); } if (wp_verify_nonce($nonce, 'backup-delete')) { $this->do_backup_delete(FW_Request::GET('post')); } if (wp_verify_nonce($nonce, 'backup-unschedule')) { $this->do_backup_unschedule(FW_Request::GET('cron')); } if (wp_verify_nonce($nonce, 'backup-download')) { $this->do_backup_download(FW_Request::GET('post')); } // Demo Install if (wp_verify_nonce($nonce, 'backup-demo-install')) { $this->do_backup_demo_install(); } // Restore if ($this->is_backup_restore()) { $this->do_backup_restore(FW_Request::GET('post')); } }
/** * If now is a submit of this form * @return bool */ public function is_submitted() { if (is_null($this->is_submitted)) { switch (strtoupper($this->attr('method'))) { case 'POST': $this->is_submitted = isset($_POST[self::$id_input_name]) && FW_Request::POST(self::$id_input_name) === $this->id; break; case 'GET': $this->is_submitted = isset($_GET[self::$id_input_name]) && FW_Request::GET(self::$id_input_name) === $this->id; break; default: $this->is_submitted = false; } } return $this->is_submitted; }