public function process_form($form_values, $data)
 {
     $flash_id = 'fw_ext_contact_form_process';
     if (empty($form_values)) {
         FW_Flash_Messages::add($flash_id, __('Unable to process the form', 'fw'), 'error');
         return;
     }
     $form_id = FW_Request::POST('fw_ext_forms_form_id');
     if (empty($form_id)) {
         FW_Flash_Messages::add($flash_id, __('Unable to process the form', 'fw'), 'error');
     }
     $form = $this->get_db_data($this->get_name() . '-' . $form_id);
     if (empty($form)) {
         FW_Flash_Messages::add($flash_id, __('Unable to process the form', 'fw'), 'error');
     }
     $to = $form['email_to'];
     if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
         FW_Flash_Messages::add($flash_id, __('Invalid destination email (please contact the site administrator)', 'fw'), 'error');
         return;
     }
     $entry_data = array('form_values' => $form_values, 'shortcode_to_item' => $data['shortcode_to_item']);
     $result = fw_ext_mailer_send_mail($to, $this->get_db_data($this->get_name() . '-' . $form_id . '/subject_message', ''), $this->render_view('email', $entry_data), $entry_data);
     if ($result['status']) {
         FW_Flash_Messages::add($flash_id, $this->get_db_data($this->get_name() . '-' . $form_id . '/success_message', __('Message sent!', 'fw')), 'success');
     } else {
         FW_Flash_Messages::add($flash_id, $this->get_db_data($this->get_name() . '-' . $form_id . '/failure_message', __('Oops something went wrong.', 'fw')) . ' <em style="color:transparent;">' . $result['message'] . '</em>', 'error');
     }
 }
 public function _ajax_get_results_json_ajax()
 {
     $this->load_data();
     $data_provider = FW_Request::POST('data_provider');
     $result = call_user_func($this->data[$data_provider]['callback'], FW_Request::POST());
     wp_send_json_success($result);
 }
 /**
  * @internal
  */
 public function _theme_action_print_saved_css()
 {
     $stored_style = FW_Request::COOKIE($this->cache_key);
     if (!empty($this->options['predefined'][$stored_style])) {
         echo $this->generate_initial_css($this->options['blocks'], $this->options['predefined'][$stored_style]);
     }
 }
function delete_builder_template()
{
    $path = 'builder_template/' . $_POST['builder_type'];
    $db_options = fw_get_db_settings_option($path);
    fw_aku(FW_Request::POST('uniqid'), $db_options);
    fw_set_db_settings_option($path, $db_options);
}
 /**
  * @internal
  */
 public static function _admin_action_get_ajax_response()
 {
     /**
      * @var WPDB $wpdb
      */
     global $wpdb;
     $type = FW_Request::POST('data/type');
     $names = json_decode(FW_Request::POST('data/names'), true);
     $title = FW_Request::POST('data/string');
     $items = array();
     switch ($type) {
         case 'posts':
             $items = $wpdb->get_results(call_user_func_array(array($wpdb, 'prepare'), array_merge(array("SELECT ID val, post_title title " . "FROM {$wpdb->posts} " . "WHERE post_title LIKE %s " . "AND post_status IN ( 'publish', 'private' ) " . "AND post_type IN ( " . implode(', ', array_fill(1, count($names), '%s')) . " ) " . "LIMIT 100", '%' . $wpdb->esc_like($title) . '%'), $names)));
             break;
         case 'taxonomy':
             $items = $wpdb->get_results(call_user_func_array(array($wpdb, 'prepare'), array_merge(array("SELECT terms.term_id val, terms.name title " . "FROM {$wpdb->terms} as terms, {$wpdb->term_taxonomy} as taxonomies " . "WHERE terms.name LIKE %s AND taxonomies.taxonomy IN ( " . implode(', ', array_fill(1, count($names), '%s')) . " ) " . "AND terms.term_id = taxonomies.term_id " . "AND taxonomies.term_id = taxonomies.term_taxonomy_id " . "LIMIT 100", '%' . $wpdb->esc_like($title) . '%'), $names)));
             break;
         case 'users':
             if (empty($names)) {
                 $items = $wpdb->get_results($wpdb->prepare("SELECT users.id val, users.user_nicename title " . "FROM {$wpdb->users} as users " . "WHERE users.user_nicename LIKE %s " . "LIMIT 100", '%' . $wpdb->esc_like($title) . '%'));
             } else {
                 $like_user_meta = array();
                 foreach ($names as $name) {
                     $like_user_meta[] = '%' . $wpdb->esc_like($name) . '%';
                 }
                 $items = $wpdb->get_results(call_user_func_array(array($wpdb, 'prepare'), array_merge(array("SELECT users.id val, users.user_nicename title " . "FROM {$wpdb->users} as users, {$wpdb->usermeta} as usermeta " . "WHERE users.user_nicename LIKE %s AND usermeta.meta_key = 'wp_capabilities' " . "AND ( " . implode(' OR ', array_fill(1, count($like_user_meta), 'usermeta.meta_value LIKE %s')) . " ) " . "AND usermeta.user_id = users.ID", '%' . $wpdb->esc_like($title) . '%'), $like_user_meta)));
             }
             break;
     }
     wp_send_json_success($items);
 }
 /**
  * @internal
  */
 public function _admin_action_wp_ajax_backup_feedback()
 {
     $subject = FW_Request::POST('subject');
     if ($feedback = $this->backup()->get_feedback($subject)) {
         $html = $this->backup()->render_str('feedback', compact('subject'));
         wp_send_json_success(compact('html'));
     }
     wp_send_json_error(array('error' => 'No feedback was found'));
 }
 /**
  * @internal
  */
 public function _form_render($data)
 {
     $this->add_admin_static();
     $options = array(array('custom_css' => array('title' => false, 'type' => 'box', 'options' => self::$user_options)));
     $values = FW_Request::POST(FW_Option_Type::get_default_name_prefix(), fw_get_db_extension_data($this->get_name(), 'options'));
     echo fw()->backend->render_options($options, $values);
     $data['submit']['html'] = '<button class="button-primary button-large">' . __('Save', 'fw') . '</button>';
     unset($options);
     return $data;
 }
 public function _action_admin_save_shortcodes($post_id, $post)
 {
     if (wp_is_post_autosave($post_id)) {
         $original_id = wp_is_post_autosave($post_id);
         $original_post = get_post($original_id);
     } else {
         if (wp_is_post_revision($post_id)) {
             $original_id = wp_is_post_revision($post_id);
             $original_post = get_post($original_id);
         } else {
             $original_id = $post_id;
             $original_post = $post;
         }
     }
     if (!$this->is_supported_post($original_id) || !post_type_supports($original_post->post_type, $this->get_parent()->get_supports_feature_name())) {
         return false;
     }
     // todo: field 'content' smth changes ?
     $post_content = FW_Request::POST('content');
     // {"notification":{"1":{"message":"Message!","type":""}},"button":{"1":{},"2":{}},"text_block":{"1":{}}}
     $input_value = FW_Request::POST($this->meta_key);
     $tmp_val = json_decode($input_value, true);
     $new_val = array();
     // supported shortcodes
     $tags = implode('|', array_keys(fw_ext('shortcodes')->get_shortcodes()));
     $default_values = array();
     // only supported tags & integer\alphabetic string id
     if (preg_match_all('/\\[(' . $tags . ')(?:\\s+[^\\[\\]]*)fw_shortcode_id=[\\"\']([A-Za-z0-9]+)[\\"\'](?:\\s?[^\\[\\]]*)\\]/', $post_content, $output_array)) {
         foreach ($output_array[0] as $match_key => $match) {
             $tag = $output_array[1][$match_key];
             $id = $output_array[2][$match_key];
             if (!isset($tmp_val[$tag]) || !isset($tmp_val[$tag][$id]) || empty($tmp_val[$tag][$id])) {
                 $shortcode = fw_ext('shortcodes')->get_shortcode($tag);
                 if ($shortcode) {
                     $new_val[$tag][$id] = fw_get_options_values_from_input($shortcode->get_options(), array());
                 }
             } elseif (isset($tmp_val[$tag][$id]) and false === empty($tmp_val[$tag][$id])) {
                 $new_val[$tag][$id] = $tmp_val[$tag][$id];
             }
         }
     }
     // only supported tags match (defaults)
     if (preg_match_all('/\\[(' . $tags . ')(?:\\s+[^\\[\\]]*).*(?:\\s?[^\\[\\]]*)\\]/', $post_content, $output_array)) {
         foreach ($output_array[0] as $match_key => $match) {
             $tag = $output_array[1][$match_key];
             $shortcode = fw_ext('shortcodes')->get_shortcode($tag);
             if (!empty($shortcode) && is_array($shortcode->get_options())) {
                 $default_values[$tag] = fw_get_options_values_from_input($shortcode->get_options(), array());
             }
         }
     }
     update_post_meta($post_id, $this->meta_key_defaults, str_replace('\\', '\\\\', json_encode($default_values)));
     update_post_meta($post_id, $this->meta_key, str_replace('\\', '\\\\', json_encode($new_val)));
     return true;
 }
 public static function _action_ajax_unset_storage_item()
 {
     if (!current_user_can('edit_posts')) {
         wp_send_json_error();
     }
     $storage_items = self::get_storage_items();
     $key = array_search((int) FW_Request::POST('post_id'), $storage_items);
     unset($storage_items[$key]);
     self::set_storage_items($storage_items);
     wp_send_json_success();
 }
 public static function _action_get_oembed_response()
 {
     if (wp_verify_nonce(FW_Request::POST('_nonce'), '_action_get_oembed_response')) {
         $url = FW_Request::POST('url');
         $width = FW_Request::POST('preview/width');
         $height = FW_Request::POST('preview/height');
         $keep_ratio = FW_Request::POST('preview/keep_ratio') === 'true';
         $iframe = empty($keep_ratio) ? fw_oembed_get($url, compact('width', 'height')) : wp_oembed_get($url, compact('width', 'height'));
         wp_send_json_success(array('response' => $iframe));
     }
     wp_send_json_error(array('message' => 'Invalid nonce'));
 }
 /**
  * @internal
  */
 protected function _init()
 {
     if (!is_admin()) {
         // loads the shortcodes
         add_action('fw_extensions_init', array($this, '_action_fw_extensions_init'));
         // renders the shortcodes so that css will get in <head>
         add_action('wp_enqueue_scripts', array($this, '_action_enqueue_shortcodes_static_in_frontend_head'));
     } elseif (defined('DOING_AJAX') && DOING_AJAX === true && FW_Request::POST('fw_load_shortcodes')) {
         // load the shortcodes if this was requested via ajax
         add_action('fw_extensions_init', array($this, '_action_fw_extensions_init'));
     }
 }
Пример #12
0
 public static function _action_ajax_delete_template()
 {
     if (!current_user_can('edit_posts')) {
         wp_send_json_error();
     }
     $builder_type = (string) FW_Request::POST('builder_type');
     if (empty($builder_type) || !fw()->backend->option_type($builder_type) || !fw()->backend->option_type($builder_type) instanceof FW_Option_Type_Builder) {
         wp_send_json_error();
     }
     $templates = self::get_templates($builder_type);
     unset($templates[(string) FW_Request::POST('uniqid')]);
     self::set_templates($builder_type, $templates);
     wp_send_json_success();
 }
 /**
  * @internal
  */
 public static function _action_ajax_cache_slide()
 {
     $output = '';
     $attr_data = json_decode(FW_Request::POST('option'), true);
     $option = $attr_data['option'];
     $id = $attr_data['id'];
     $data = $attr_data['data'];
     parse_str(FW_Request::POST('values'), $values);
     if (isset($values)) {
         $options_values_cache = $values['fw_options']['custom-slides'];
         $options_values = array_pop($options_values_cache);
         $valid_values = fw_get_options_values_from_input($option['slides_options'], $options_values);
         foreach ($values['fw_options']['custom-slides'] as $key => $value) {
             $output .= "<div class='fw-slide slide-" . $key . "'  data-order='" . $key . "'>";
             $output .= fw()->backend->render_options($option['slides_options'], $valid_values, array('id_prefix' => $data['id_prefix'] . $id . '-' . $key . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . $key . ']'));
             $output .= "</div>";
         }
     }
     wp_send_json($output);
 }
 /**
  * {@inheritdoc}
  */
 public function frontend_validate(array $item, $input_value)
 {
     $mesages = array('not-configured' => __('Could not validate the form', 'fw'), 'not-human' => __('Please fill the recaptcha', 'fw'));
     $keys = fw_ext('forms')->get_db_settings_option('recaptcha-keys');
     if (empty($keys)) {
         return $mesages['not-configured'];
     }
     $recaptcha = new ReCaptcha($keys['secret-key']);
     $gRecaptchaResponse = FW_Request::POST('g-recaptcha-response');
     if (empty($gRecaptchaResponse)) {
         return $mesages['not-human'];
     }
     $resp = $recaptcha->verify($gRecaptchaResponse);
     if ($resp->isSuccess()) {
         return false;
     } else {
         $errors = $resp->getErrorCodes();
         return $mesages['not-human'];
     }
 }
 /**
  * @internal
  */
 public static function _action_ajax_render()
 {
     if (!current_user_can('edit_posts')) {
         wp_send_json_error();
     }
     $builder_type = (string) FW_Request::POST('builder_type');
     if (!fw()->backend->option_type($builder_type)) {
         wp_send_json_error();
     }
     $first = true;
     $html = '<div class="fw-builder-templates-types">';
     foreach (self::get_components() as $component) {
         $component_html = $component->_render(array('builder_type' => $builder_type));
         if (empty($component_html)) {
             continue;
         }
         $html .= '<div class="fw-builder-templates-type fw-builder-templates-type-' . esc_attr($component->get_type()) . '"' . ' data-type="' . esc_attr($component->get_type()) . '">' . '<a class="fw-builder-templates-type-title" href="#" onclick="return false;">' . $component->get_title() . '</a>' . '<div class="fw-builder-templates-type-content' . ($first ? '' : ' fw-hidden') . '">' . $component_html . '</div>' . '</div>';
         $first = false;
         unset($component_html);
     }
     $html .= '</div>';
     wp_send_json_success(array('html' => $html));
 }
 /**
  * @internal
  */
 public function wp_verify_nonce($action)
 {
     $nonce = FW_Request::GET('_wpnonce');
     return $nonce && wp_verify_nonce($nonce, $action);
 }
 /**
  * @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;
 }
Пример #18
0
 public function _settings_form_render($data)
 {
     /**
      * wp moves flash message error with js after first h2
      * if there are any h2 on the page it shows it wrong
      */
     echo '<h2 class="fw-hidden"></h2>';
     $options = fw()->theme->get_settings_options();
     if (empty($options)) {
         return $data;
     }
     $values = FW_Request::POST(FW_Option_Type::get_default_name_prefix(), fw_get_db_settings_option());
     echo fw()->backend->render_options($options, $values);
     $data['submit']['html'] = '<button class="button-primary button-large">' . __('Save', 'fw') . '</button>';
     return $data;
 }
 /**
  * @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;
         }
     }
 }
<?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 ? '' : ' &nbsp;&nbsp; ';
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
			);
		});
 /**
  * @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;
 }
 /**
  * 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));
 }
Пример #23
0
 /**
  * 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;
 }
Пример #24
0
/**
 * Get correct values from input (POST) for given options
 * This values can be saved in db then replaced with $option['value'] for each option
 * @param array $options
 * @param array $input_array
 * @return array Values
 */
function fw_get_options_values_from_input(array $options, $input_array = null)
{
    if (!is_array($input_array)) {
        $input_array = FW_Request::POST(FW_Option_Type::get_default_name_prefix());
    }
    $values = array();
    foreach (fw_extract_only_options($options) as $id => $option) {
        $values[$id] = fw()->backend->option_type($option['type'])->get_value_from_input($option, isset($input_array[$id]) ? $input_array[$id] : null);
        if (is_null($values[$id])) {
            // do not save null values
            unset($values[$id]);
        }
    }
    return $values;
}
Пример #25
0
 public function _settings_form_render($data)
 {
     $this->enqueue_options_static(array());
     wp_enqueue_script('fw-form-helpers');
     $options = fw()->theme->get_settings_options();
     if (empty($options)) {
         return $data;
     }
     if ($values = FW_Request::POST(FW_Option_Type::get_default_name_prefix())) {
         // This is form submit, extract correct values from $_POST values
         $values = fw_get_options_values_from_input($options, $values);
     } else {
         // Extract previously saved correct values
         $values = fw_get_db_settings_option();
     }
     $ajax_submit = fw()->theme->get_config('settings_form_ajax_submit');
     $side_tabs = fw()->theme->get_config('settings_form_side_tabs');
     $data['attr']['class'] = 'fw-settings-form';
     if ($side_tabs) {
         $data['attr']['class'] .= ' fw-backend-side-tabs';
     }
     $data['submit']['html'] = '<!-- -->';
     // is generated in view
     do_action('fw_settings_form_render', array('ajax_submit' => $ajax_submit, 'side_tabs' => $side_tabs));
     fw_render_view(fw_get_framework_directory('/views/backend-settings-form.php'), array('options' => $options, 'values' => $values, 'reset_input_name' => '_fw_reset_options', 'ajax_submit' => $ajax_submit, 'side_tabs' => $side_tabs), false);
     return $data;
 }
 public function _filter_verify_comment_meta_data($comment_data)
 {
     if ($this->accept_stars($comment_data['comment_post_ID']) && intval(FW_Request::POST($this->field_name)) < 1) {
         wp_die('<strong>' . __('ERROR', 'fw') . '</strong>' . ': ' . __('please rate the post.', 'fw'));
     }
     return $comment_data;
 }
Пример #27
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();
     $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;
 }
 /**
  * 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);
     }
 }
 /**
  * @internal
  */
 public function _admin_action_add_new_sidebar_ajax()
 {
     $name = FW_Request::POST('name');
     $result = $this->backend->save_new_sidebar($name);
     $this->ajax_response($result);
 }
 /**
  * @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;
 }