Esempio n. 1
1
 public function _settings_form_save($data)
 {
     fw_set_db_settings_option(null, array_merge((array) fw_get_db_settings_option(), fw_get_options_values_from_input(fw()->theme->get_settings_options())));
     FW_Flash_Messages::add('fw_settings_form_saved', __('Options successfuly saved', 'fw'), 'success');
     $data['redirect'] = fw_current_url();
     return $data;
 }
 /**
  * @internal
  */
 public function _form_save($data)
 {
     fw_set_db_extension_data($this->get_name(), 'options', fw_get_options_values_from_input($this->get_settings_options()));
     do_action('fw_' . $this->get_name() . '_form_save');
     $data['redirect'] = fw_current_url();
     return $data;
 }
Esempio n. 3
0
 /**
  * @param string $id Unique
  * @param array $data (optional)
  * array(
  *  'render'   => callback // The callback that will render the form's html
  *  'validate' => callback // The callback that will validate user input
  *  'save'     => callback // The callback that will save successfully validated user input
  *  'attr'     => array()  // Custom <form ...> attributes
  * )
  */
 public function __construct($id, $data = array())
 {
     if (isset(self::$forms[$id])) {
         trigger_error(sprintf(__('Form with id "%s" was already defined', 'fw'), $id), E_USER_ERROR);
     }
     $this->id = $id;
     self::$forms[$this->id] =& $this;
     if (!isset($data['attr']) || !is_array($data['attr'])) {
         $data['attr'] = array();
     }
     $data['attr']['data-fw-form-id'] = $this->id;
     /** @deprecated */
     $data['attr']['class'] = 'fw_form_' . $this->id;
     if (isset($data['attr']['method'])) {
         $data['attr']['method'] = strtolower($data['attr']['method']);
         $data['attr']['method'] = in_array($data['attr']['method'], array('get', 'post')) ? $data['attr']['method'] : 'post';
     } else {
         $data['attr']['method'] = 'post';
     }
     if (!isset($data['attr']['action'])) {
         $data['attr']['action'] = fw_current_url();
     }
     $this->attr = $data['attr'];
     $this->callbacks = array('render' => empty($data['render']) ? false : $data['render'], 'validate' => empty($data['validate']) ? false : $data['validate'], 'save' => empty($data['save']) ? false : $data['save']);
     if (did_action('wp_loaded')) {
         // in case if form instance was created after action
         $this->_validate_and_save();
     } else {
         // attach to an action before 'send_headers' action, to be able to do redirects
         add_action('wp_loaded', array($this, '_validate_and_save'), 101);
     }
 }
 /**
  * Request WP Filesystem access
  * @param string $context
  * @param string $url
  * @param array $extra_fields
  * @return null|bool // todo: Create a new method that will return WP_Error with message on failure
  *      null  - if has no access and the input credentials form was displayed
  *      false - if user submitted wrong credentials
  *      true  - if we have filesystem access
  */
 public static final function request_access($context = null, $url = null, $extra_fields = array())
 {
     /** @var WP_Filesystem_Base $wp_filesystem */
     global $wp_filesystem;
     if ($wp_filesystem) {
         // already initialized (has access)
         return true;
     }
     if (empty($url)) {
         $url = fw_current_url();
     }
     if (get_filesystem_method() === 'direct') {
         // in case if direct access is available
         /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
         $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, null);
         /* initialize the API */
         if (!WP_Filesystem($creds)) {
             /* any problems and we exit */
             trigger_error(__('Cannot connect to Filesystem directly', 'fw'), E_USER_WARNING);
             return false;
         }
     } else {
         $creds = request_filesystem_credentials($url, '', false, $context, $extra_fields);
         if (!$creds) {
             // the form was printed to the user
             return null;
         }
         /* initialize the API */
         if (!WP_Filesystem($creds)) {
             /* any problems and we exit */
             request_filesystem_credentials($url, '', true, $context, $extra_fields);
             // the third parameter is true to show error to the user
             return false;
         }
     }
     global $wp_filesystem;
     if (!is_object($wp_filesystem)) {
         return false;
     }
     if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
         return false;
     }
     if ($wp_filesystem->abspath() && $wp_filesystem->wp_content_dir() && $wp_filesystem->wp_plugins_dir() && $wp_filesystem->wp_themes_dir() && $wp_filesystem->find_folder($context)) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 5
0
 public function _settings_form_save($data)
 {
     $flash_id = 'fw_settings_form_save';
     $old_values = (array) fw_get_db_settings_option();
     if (!empty($_POST['_fw_reset_options'])) {
         // The "Reset" button was pressed
         fw_set_db_settings_option(null, array());
         FW_Flash_Messages::add($flash_id, __('The options were successfully reset', 'fw'), 'success');
         do_action('fw_settings_form_reset', $old_values);
     } else {
         // The "Save" button was pressed
         fw_set_db_settings_option(null, fw_get_options_values_from_input(fw()->theme->get_settings_options()));
         FW_Flash_Messages::add($flash_id, __('The options were successfully saved', 'fw'), 'success');
         do_action('fw_settings_form_saved', $old_values);
     }
     $redirect_url = fw_current_url();
     $data['redirect'] = $redirect_url;
     return $data;
 }
 private function restore_run($post_id)
 {
     /**
      * @var FW_Backup_Service_Post_Meta $meta
      * @var FW_Backup_Interface_Storage $storage
      * @var FW_Backup_Process_Backup_Restore $backup_restore
      * @var WP_Filesystem_Base $wp_filesystem
      */
     global $wp_filesystem;
     ob_start();
     $credentials = request_filesystem_credentials(fw_current_url(), '', false, false, null);
     $this->request_filesystem_credentials = ob_get_clean();
     if ($credentials) {
         if (!WP_Filesystem($credentials)) {
             ob_start();
             request_filesystem_credentials(fw_current_url(), '', false, false, null);
             $this->request_filesystem_credentials = ob_get_clean();
         }
     }
     if ($this->request_filesystem_credentials) {
         return false;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         return false;
     }
     //		ob_start();
     //		fw_print('Let\'s start the party!!!');
     //		$this->request_filesystem_credentials = ob_get_clean();
     //		return;
     set_time_limit(0);
     $meta = $this->service('shared.post.meta');
     $meta->set_post_id($post_id);
     $storage = $this->service($meta->get_storage_id(), 'FW_Backup_Interface_Storage');
     $backup_restore = $this->service('process.backup-restore', 'FW_Backup_Process_Backup_Restore');
     // 1) Do we have enough permissions for restoring file system / database?
     //    If no there is no need for fetching archive.
     if (in_array('fs', $meta->get_backup_contents())) {
         $backup_restore->check_permissions_fs();
     }
     if (in_array('db', $meta->get_backup_contents())) {
         $backup_restore->check_permissions_db();
     }
     // 2) Do restore
     $backup_restore->restore($storage, $meta->get_backup_file());
     // 3) Actualize settings
     $this->reschedule();
     FW_Flash_Messages::add(uniqid(), __('The site was restored from backup', 'fw'));
     return true;
 }
		<?php 
    }
    ?>

	</ul>

	<div class="details-event-button">
		<button data-uri="<?php 
    echo esc_url(add_query_arg(array('row_id' => $key, 'calendar' => 'google'), fw_current_url()));
    ?>
" type="button" class="btn btn-default"><?php 
    _e('Google Calendar', 'fw');
    ?>
</button>
		<button data-uri="<?php 
    echo esc_url(add_query_arg(array('row_id' => $key, 'calendar' => 'ical'), fw_current_url()));
    ?>
" type="button" class="btn btn-default"><?php 
    _e('Ical Export', 'fw');
    ?>
</button>
	</div>
	<hr class="after-hr"/>
<?php 
}
?>
<!-- .additional information about event -->

<?php 
echo $the_content;
?>
 /**
  * @param array $data
  * @return array
  * @internal
  */
 public function _extension_settings_form_save($data)
 {
     $extension = fw()->extensions->get(FW_Request::POST('fw_extension_name'));
     $options_before_save = (array) fw_get_db_ext_settings_option($extension->get_name());
     fw_set_db_ext_settings_option($extension->get_name(), null, array_merge($options_before_save, fw_get_options_values_from_input($extension->get_settings_options())));
     FW_Flash_Messages::add('fw_extension_settings_saved', __('Extensions settings successfully saved.', 'fw'), 'success');
     $data['redirect'] = fw_current_url();
     do_action('fw_extension_settings_form_saved:' . $extension->get_name(), $options_before_save);
     return $data;
 }
 /**
  * @param array $fw_form_data
  *
  * @return array
  *
  * @internal
  */
 public function _frontend_form_save($fw_form_data)
 {
     $form_id = FW_Request::POST('fw_ext_forms_form_id');
     $form_type = FW_Request::POST('fw_ext_forms_form_type');
     /**
      * @var FW_Ext_Forms_Type $form_instance
      */
     $form_instance = fw_ext($form_type);
     /**
      * @var FW_Option_Type_Form_Builder $builder
      */
     $builder = fw()->backend->option_type($form_instance->get_form_builder_type());
     /**
      * {json: '...', ...}
      */
     $builder_value = $form_instance->get_form_builder_value($form_id);
     /**
      * {[item], [item], ...}
      */
     $builder_value_json_array = json_decode($builder_value['json'], true);
     /**
      * By default redirect to the same page
      * to prevent form submit alert on page refresh
      */
     $fw_form_data['redirect'] = fw_current_url();
     if (empty($builder_value_json_array)) {
         return $fw_form_data;
     }
     /**
      * {shortcode => item}
      */
     $shortcode_to_item = array();
     $this->extract_shortcode_item($shortcode_to_item, $builder_value_json_array);
     $process_data = $form_instance->process_form($builder->frontend_get_value_from_items($builder_value_json_array, FW_Request::POST()), array('shortcode_to_item' => $shortcode_to_item, 'builder_value' => $builder_value));
     if (is_array($process_data)) {
         if (isset($process_data['redirect'])) {
             $fw_form_data['redirect'] = $process_data['redirect'];
         }
     }
     do_action('fw_ext_forms_frontend_submit', array('id' => $form_id, 'type' => $form_type, 'instance' => $form_instance, 'process_data' => $process_data));
     return $fw_form_data;
 }
 /**
  * Print column headers, accounting for hidden and sortable columns.
  *
  * @since 3.1.0
  * @access protected
  *
  * @param bool $with_id Whether to set the id attribute or not
  */
 function print_column_headers($with_id = true)
 {
     list($columns, $hidden, $sortable) = $this->get_column_info();
     $current_url = fw_current_url();
     $current_url = remove_query_arg('paged', $current_url);
     if (isset($_GET['orderby'])) {
         $current_orderby = $_GET['orderby'];
     } else {
         $current_orderby = '';
     }
     if (isset($_GET['order']) && 'desc' == $_GET['order']) {
         $current_order = 'desc';
     } else {
         $current_order = 'asc';
     }
     if (!empty($columns['cb'])) {
         static $cb_counter = 1;
         $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All', 'fw') . '</label>' . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
         $cb_counter++;
     }
     foreach ($columns as $column_key => $column_display_name) {
         $class = array('manage-column', "column-{$column_key}");
         $style = '';
         if (in_array($column_key, $hidden)) {
             $style = 'display:none;';
         }
         $style = ' style="' . $style . '"';
         if ('cb' == $column_key) {
             $class[] = 'check-column';
         } elseif (in_array($column_key, array('posts', 'comments', 'links'))) {
             $class[] = 'num';
         }
         if (isset($sortable[$column_key])) {
             list($orderby, $desc_first) = $sortable[$column_key];
             if ($current_orderby == $orderby) {
                 $order = 'asc' == $current_order ? 'desc' : 'asc';
                 $class[] = 'sorted';
                 $class[] = $current_order;
             } else {
                 $order = $desc_first ? 'desc' : 'asc';
                 $class[] = 'sortable';
                 $class[] = $desc_first ? 'asc' : 'desc';
             }
             $column_display_name = '<a href="' . esc_url(add_query_arg(compact('orderby', 'order'), $current_url)) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
         }
         $id = $with_id ? "id='{$column_key}'" : '';
         if (!empty($class)) {
             $class = "class='" . join(' ', $class) . "'";
         }
         echo "<th scope='col' {$id} {$class} {$style}>{$column_display_name}</th>";
     }
 }
 /**
  * @internal
  */
 public function _action_update_framework()
 {
     $nonce_name = '_nonce_fw_ext_update_framework';
     if (!isset($_POST[$nonce_name]) || !wp_verify_nonce($_POST[$nonce_name])) {
         wp_die(__('Invalid nonce.', 'fw'));
     }
     if (!class_exists('_FW_Ext_Update_Framework_Upgrader_Skin')) {
         fw_include_file_isolated($this->get_declared_path('/includes/classes/class--fw-ext-update-framework-upgrader-skin.php'));
     }
     $skin = new _FW_Ext_Update_Framework_Upgrader_Skin(array('title' => __('Update Framework', 'fw')));
     require_once ABSPATH . 'wp-admin/admin-header.php';
     $skin->header();
     $update = $this->get_framework_update(true);
     do {
         if ($update === false) {
             $skin->error(__('Failed to get framework latest version.', 'fw'));
             break;
         } elseif (is_wp_error($update)) {
             $skin->error($update);
             break;
         }
         $context = $this->context;
         if (!FW_WP_Filesystem::request_access($context, fw_current_url(), array($nonce_name))) {
             break;
         }
         $this->maintenance_mode(true);
         /** @var WP_Filesystem_Base $wp_filesystem */
         global $wp_filesystem;
         $tmp_download_dir = FW_WP_Filesystem::real_path_to_filesystem_path(FW_CACHE_DIR . '/update');
         // just in case it already exists, clear everything, it may contain broken/old files
         $wp_filesystem->rmdir($tmp_download_dir, true);
         if (!FW_WP_Filesystem::mkdir_recursive($tmp_download_dir)) {
             $skin->error(__('Cannot create directory: ' . $tmp_download_dir, 'fw'));
             break;
         }
         $skin->feedback(__('Downloading framework...', 'fw'));
         /** @var FW_Ext_Update_Service $service */
         $service = $this->get_child($update['service']);
         $downloaded_files_dir = $service->_download_framework($update['latest_version'], $tmp_download_dir);
         if (!$downloaded_files_dir) {
             $skin->error(__('Failed to download framework.', 'fw'));
             break;
         } elseif (is_wp_error($downloaded_files_dir)) {
             $skin->error($downloaded_files_dir);
             break;
         }
         $skin->feedback(__('Installing framework...', 'fw'));
         $framework_dir = FW_WP_Filesystem::real_path_to_filesystem_path(FW_DIR);
         // remove entire framework directory
         $wp_filesystem->rmdir($framework_dir, true);
         // move downloaded directory as new framework directory
         $wp_filesystem->move($downloaded_files_dir, $framework_dir);
         $skin->feedback(__('Framework updated.', 'fw'));
         $wp_filesystem->delete($tmp_download_dir, true, 'd');
         $skin->set_result(true);
         $skin->after();
     } while (false);
     $this->maintenance_mode(false);
     $skin->footer();
     require_once ABSPATH . 'wp-admin/admin-footer.php';
 }
 /**
  * Generate default frontend swith urls.
  *
  * @return array
  */
 private function generate_default_frontend_switch_urls()
 {
     $languages = $this->get_enabled_languages();
     $frontend_urls = array();
     global $wp_rewrite;
     $current_url = fw_current_url() === preg_replace('/(\\/fw_lang\\/)(\\w+)/ix', '', get_home_url()) ? get_home_url() : fw_current_url();
     foreach ($languages as $lang_code => $language) {
         if ($wp_rewrite->using_permalinks()) {
             $permalink = preg_replace('/(\\/fw_lang\\/)(\\w+)/ix', '${1}' . $lang_code, $current_url);
             $frontend_urls[$lang_code] = $permalink;
         } else {
             $permalink = esc_url(remove_query_arg('fw_lang', $current_url));
             $frontend_urls[$lang_code] = esc_url(add_query_arg(array('fw_lang' => $lang_code), $permalink));
         }
     }
     return $frontend_urls;
 }
 /**
  * @internal
  */
 public function _action_update_extensions()
 {
     $nonce_name = '_nonce_fw_ext_update_extensions';
     if (!isset($_POST[$nonce_name]) || !wp_verify_nonce($_POST[$nonce_name])) {
         wp_die(__('Invalid nonce.', 'fw'));
     }
     $form_input_name = 'extensions';
     $extensions_list = FW_Request::POST($form_input_name);
     if (empty($extensions_list)) {
         FW_Flash_Messages::add('fw_ext_update', __('Please check the extensions you want to update.', 'fw'), 'warning');
         wp_redirect(self_admin_url('update-core.php'));
         exit;
     }
     if (is_string($extensions_list)) {
         $extensions_list = json_decode($extensions_list);
     } else {
         $extensions_list = array_keys($extensions_list);
     }
     if (!class_exists('_FW_Ext_Update_Extensions_Upgrader_Skin')) {
         fw_include_file_isolated($this->get_declared_path('/includes/classes/class--fw-ext-update-extensions-upgrader-skin.php'));
     }
     $skin = new _FW_Ext_Update_Extensions_Upgrader_Skin(array('title' => __('Extensions Update', 'fw')));
     require_once ABSPATH . 'wp-admin/admin-header.php';
     $skin->header();
     do {
         $original_post_value = $_POST[$form_input_name];
         $_POST[$form_input_name] = wp_slash(json_encode($extensions_list));
         if (!FW_WP_Filesystem::request_access(fw_get_framework_directory('/extensions'), fw_current_url(), array($nonce_name, $form_input_name))) {
             // revert hack changes
             $_POST[$form_input_name] = $original_post_value;
             unset($original_post_value);
             break;
         }
         // revert hack changes
         $_POST[$form_input_name] = $original_post_value;
         unset($original_post_value);
         $updates = $this->get_extensions_with_updates();
         if (empty($updates)) {
             $skin->error(__('No extensions updates found.', 'fw'));
             break;
         }
         foreach ($extensions_list as $extension_name) {
             if (!($extension = fw()->extensions->get($extension_name))) {
                 $skin->error(sprintf(__('Extension "%s" does not exist or is disabled.', 'fw'), $extension_name));
                 continue;
             }
             if (!isset($updates[$extension_name])) {
                 $skin->error(sprintf(__('No update found for the "%s" extension.', 'fw'), $extension->manifest->get_name()));
                 continue;
             }
             $update = $updates[$extension_name];
             if (is_wp_error($update)) {
                 $skin->error($update);
                 continue;
             }
             /** @var FW_Ext_Update_Service $service */
             $service = $this->get_child($update['service']);
             $update_result = $this->update(array('wp_fs_destination_dir' => FW_WP_Filesystem::real_path_to_filesystem_path($extension->get_declared_path()), 'download_callback' => array($service, '_download_extension'), 'download_callback_args' => array($extension, $update['latest_version'], $this->get_wp_fs_tmp_dir()), 'skin' => $skin, 'title' => sprintf(__('%s extension', 'fw'), $extension->manifest->get_name())), true);
             if (is_wp_error($update_result)) {
                 $skin->error($update_result);
                 continue;
             }
             $skin->set_result(true);
             if (!$this->get_config('extensions_as_one_update')) {
                 $skin->decrement_extension_update_count($extension_name);
             }
         }
         if ($this->get_config('extensions_as_one_update')) {
             $skin->decrement_extension_update_count($extension_name);
         }
         $skin->after();
     } while (false);
     $skin->footer();
     require_once ABSPATH . 'wp-admin/admin-footer.php';
 }
 /**
  * Determine the current frontend page location, in creates the breadcrumbs array
  * @return array
  */
 private function build_breadcrumbs()
 {
     if (is_admin()) {
         return array();
     }
     if (did_action('wp') == 0) {
         return array();
     }
     $return = array(0 => array('name' => $this->settings['labels']['homepage-title'], 'url' => home_url(), 'type' => 'front_page'));
     $custom_page = apply_filters('fw_ext_breadcrumbs_current_page', array());
     if (is_array($custom_page) && !empty($custom_page)) {
         $return[] = $custom_page;
         $return = apply_filters('fw_ext_breadcrumbs_build', $return);
         return $return;
     }
     if (is_404()) {
         $page = array();
         $page['type'] = '404';
         $page['name'] = $this->settings['labels']['404-title'];
         $page['url'] = fw_current_url();
         $return[] = $page;
     } elseif (is_search()) {
         $search = array();
         $search['type'] = 'search';
         $search['name'] = __('Searching for:', 'fw') . ' ' . get_search_query();
         $s = '?s=' . apply_filters('fw_ext_breadcrumbs_search_query', get_search_query());
         $search['url'] = home_url('/') . $s;
         $return[] = $search;
     } elseif (is_front_page()) {
     } elseif (is_home()) {
         $blog = array('name' => $this->settings['labels']['blogpage-title'], 'url' => fw_current_url(), 'type' => 'front_page');
         $return[] = $blog;
     } elseif (is_page()) {
         global $post;
         $return = array_merge($return, array_reverse($this->get_page_hierarchy($post->ID)));
     } elseif (is_single()) {
         global $post;
         $taxonomies = get_object_taxonomies($post->post_type, 'objects');
         $slugs = array();
         if (!empty($taxonomies)) {
             foreach ($taxonomies as $key => $tax) {
                 if ($tax->show_ui === true && $tax->public === true && $tax->hierarchical !== false) {
                     array_push($slugs, $tax->name);
                 }
             }
             $terms = wp_get_post_terms($post->ID, $slugs);
             if (!empty($terms)) {
                 $term = array_shift($terms);
                 unset($terms);
                 $return = array_merge($return, array_reverse($this->get_term_hierarchy($term->term_id, $term->taxonomy)));
             }
         }
         $return = array_merge($return, array_reverse($this->get_page_hierarchy($post->ID)));
     } elseif (is_category()) {
         $term_id = get_query_var('cat');
         $return = array_merge($return, array_reverse($this->get_term_hierarchy($term_id, 'category')));
     } elseif (is_tag()) {
         $term_id = get_query_var('tag');
         $term = get_term_by('slug', $term_id, 'post_tag');
         if (empty($term) || is_wp_error($term)) {
             return array();
         }
         $tag = array();
         $tag['type'] = 'taxonomy';
         $tag['name'] = $term->name;
         $tag['url'] = get_term_link($term_id, 'post_tag');
         $tag['taxonomy'] = 'post_tag';
         $return[] = $tag;
     } elseif (is_tax()) {
         $term_id = get_queried_object()->term_id;
         $taxonomy = get_query_var('taxonomy');
         $return = array_merge($return, array_reverse($this->get_term_hierarchy($term_id, $taxonomy)));
     } elseif (is_author()) {
         $author = array();
         $author['name'] = get_queried_object()->data->display_name;
         $author['id'] = get_queried_object()->data->ID;
         $author['url'] = get_author_posts_url($author['id'], get_queried_object()->data->user_nicename);
         $author['type'] = 'author';
         $return[] = $author;
     } elseif (is_date()) {
         $date = array();
         if (get_option('permalink_structure')) {
             $day = get_query_var('day');
             $month = get_query_var('monthnum');
             $year = get_query_var('year');
         } else {
             $m = get_query_var('m');
             $year = substr($m, 0, 4);
             $month = substr($m, 4, 2);
             $day = substr($m, 6, 2);
         }
         if (is_day()) {
             $date['name'] = mysql2date(apply_filters('fw_ext_breadcrumbs_date_day_format', 'd F Y'), $day . '-' . $month . '-' . $year);
             $date['url'] = get_day_link($year, $month, $day);
             $date['date_type'] = 'daily';
             $date['day'] = $day;
             $date['month'] = $month;
             $date['year'] = $year;
         } elseif (is_month()) {
             $date['name'] = mysql2date(apply_filters('fw_ext_breadcrumbs_date_month_format', 'F Y'), '01.' . $month . '.' . $year);
             $date['url'] = get_month_link($year, $month);
             $date['date_type'] = 'monthly';
             $date['month'] = $month;
             $date['year'] = $year;
         } else {
             $date['name'] = mysql2date(apply_filters('fw_ext_breadcrumbs_date_year_format', 'Y'), '01.01.' . $year);
             $date['url'] = get_year_link($year);
             $date['date_type'] = 'yearly';
             $date['year'] = $year;
         }
         $return[] = $date;
     } elseif (is_archive()) {
         $post_type = get_query_var('post_type');
         if ($post_type) {
             $post_type = get_post_type_object($post_type);
             $archive = array();
             $archive['name'] = $post_type->labels->name;
             $return[] = $archive;
         }
     }
     foreach ($return as $key => $item) {
         if (empty($item['name'])) {
             $return[$key]['name'] = __('No title', 'fw');
         }
     }
     /* Reserved for pagination
     		 * global $wp_query;
     		$paged = array();
     		$paged['name'] = get_query_var('paged');
     		$paged['max_pages'] = $wp_query->max_num_pages;
     		if( intval( $paged['name'] ) > 0 ){
     			$paged['name'] = __('Page', 'fw') . ' ' . $paged['name'];
     			$return[] = $paged;
     		}*/
     $return = apply_filters('fw_ext_breadcrumbs_build', $return);
     return $return;
 }
 public function request_filesystem_credentials()
 {
     ob_start();
     $credentials = request_filesystem_credentials(fw_current_url(), '', false, false, null);
     $request_filesystem_credentials = ob_get_clean();
     if ($credentials) {
         if (!WP_Filesystem($credentials)) {
             ob_start();
             request_filesystem_credentials(fw_current_url(), '', false, false, null);
             $request_filesystem_credentials = ob_get_clean();
         }
     }
     if ($request_filesystem_credentials) {
         throw new FW_Backup_Exception_Request_File_System_Credentials($request_filesystem_credentials);
     }
 }
Esempio n. 16
-5
 public function _settings_form_save($data)
 {
     $flash_id = 'fw_settings_form_save';
     $old_values = (array) fw_get_db_settings_option();
     if (!empty($_POST['_fw_reset_options'])) {
         // The "Reset" button was pressed
         fw_set_db_settings_option(null, array());
         FW_Flash_Messages::add($flash_id, __('The options were successfully reset', 'fw'), 'success');
         do_action('fw_settings_form_reset', $old_values);
     } else {
         // The "Save" button was pressed
         fw_set_db_settings_option(null, array_merge($old_values, fw_get_options_values_from_input(fw()->theme->get_settings_options())));
         FW_Flash_Messages::add($flash_id, __('The options were successfully saved', 'fw'), 'success');
         do_action('fw_settings_form_saved', $old_values);
     }
     $redirect_url = fw_current_url();
     $focus_tab_input_name = '_focus_tab';
     $focus_tab_id = trim(FW_Request::POST($focus_tab_input_name));
     if (!empty($focus_tab_id)) {
         $redirect_url = add_query_arg($focus_tab_input_name, $focus_tab_id, remove_query_arg($focus_tab_input_name, $redirect_url));
     }
     $data['redirect'] = $redirect_url;
     return $data;
 }