public function get_max_rating() { if (is_null($this->max_rating)) { $this->max_rating = intval(fw_get_db_ext_settings_option('feedback', 'feedback_stars_stars_number', 5)); } return $this->max_rating; }
/** * Call add_post_type_support('{post-type}', 'fw-page-builder') * for post types checked on Page Builder Settings page. */ function _action_fw_ext_page_builder_add_support() { $feature_name = fw_ext('page-builder')->get_supports_feature_name(); foreach (array_keys(fw_get_db_ext_settings_option('page-builder', 'post_types')) as $slug) { add_post_type_support($slug, $feature_name); } }
/** * CHECK IF THE PURCHASE CODE IS VALID */ public function woffice_tf_check() { /* We get the data from the OPTIONS */ $tf_username = fw_get_db_ext_settings_option('woffice-updater', 'tf_username'); $tf_purchasecode = fw_get_db_ext_settings_option('woffice-updater', 'tf_purchasecode'); if (empty($tf_username) || empty($tf_purchasecode)) { return; } $request_string = array('body' => array('action' => 'check_purchase', 'username' => htmlspecialchars($tf_username), 'purchase_code' => htmlspecialchars($tf_purchasecode))); /* We use our API */ $raw_response = wp_remote_post('http://alka-web.com/woffice-updater/theme-updater.php', $request_string); /* We check */ $response = null; if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200) { $response = $raw_response['body']; } if (!empty($response)) { if ($response == 'true') { /*If it works we save that data in the options table*/ update_option('woffice_license', 'checked'); return true; } else { update_option('woffice_license', 'not-checked'); return; } } }
/** * Registers support of feedback for post types checked in dashboard. * @internal */ public function _action_add_feedback_support() { $post_types = fw_get_db_ext_settings_option('feedback', 'post_types', array('post' => true)); foreach ($post_types as $slug => $value) { add_post_type_support($slug, 'comments'); add_post_type_support($slug, $this->supports_feature_name); } }
/** * @internal */ public function _theme_action_print_styling_switcher() { echo $this->render_view('panel', array('options' => $this->options, 'description' => fw_get_db_ext_settings_option($this->get_parent()->get_name(), 'switch_style_panel_description'))); wp_enqueue_style('fw-ext-' . $this->get_name(), $this->locate_URI('/static/css/panel.css'), array(), fw()->theme->manifest->get_version()); wp_enqueue_script('fw-ext-' . $this->get_name(), $this->locate_URI('/static/js/panel.js'), array('jquery'), fw()->theme->manifest->get_version()); wp_localize_script('fw-ext-' . $this->get_name(), 'fwGoogleFonts', fw_get_google_fonts()); wp_localize_script('fw-ext-' . $this->get_name(), 'fwSwitchStylePanel', array('cache_key' => $this->cache_key)); }
public function _init() { new ns_add_category_image(); $visual_editor = fw_get_db_ext_settings_option('ns-category-features', 'visual_desc', ''); //enable visual editor if ($visual_editor == 'yes') { add_action('wp_loaded', array($this, 'visual_term_description_editor'), 999); } }
/** * This checks on which page we're and display the correct breancrumb navigation * @return string | void */ public function output_html() { global $post, $cat, $wp_query; $output = ''; $arc_year = get_the_time('Y'); $arc_month = get_the_time('F'); $arc_day = get_the_time('d'); $arc_day_full = get_the_time('l'); $url_year = get_year_link($arc_year); $url_month = get_month_link($arc_year, $arc_month); $templates = array_keys(fw_get_db_ext_settings_option('ns-breadcrumb', 'hide-bdb-templates', array())); $types = array_keys(fw_get_db_ext_settings_option('ns-breadcrumb', 'hide-bdb-types', array())); if (in_array(get_post_type(), $types)) { return; } if (!is_front_page()) { //breadcrumb for single post if (is_single() && !in_array('single', $templates)) { $output = $this->is_single_post(); } elseif (is_category() && !in_array('category', $templates)) { $output = '<li>' . $this->set_opt('category') . get_category_parents($cat, true, ' » ') . '</li>'; } elseif (is_tax() && !in_array('category', $templates)) { $term = $wp_query->queried_object; $output = '<li>' . $this->set_opt('category') . $term->name . '</li>'; } elseif (is_tag() && !in_array('tag', $templates)) { $output = '<li>' . $this->set_opt('tags') . single_tag_title('', false) . '</li>'; } elseif (is_day() && !in_array('archive', $templates)) { $output = '<li><a href="' . $url_year . '">' . $arc_year . '</a></li>'; $output .= '<li><a href="' . $url_month . '">' . $arc_month . '</a></li><li>' . $arc_day . ' (' . $arc_day_full . ')</li>'; } elseif (is_month() && !in_array('archive', $templates)) { $output = '<li><a href="' . $url_year . '">' . $arc_year . '</a></li><li>' . $arc_month . '</li>'; } elseif (is_year() && !in_array('archive', $templates)) { $output = '<li>' . $arc_year . '</li>'; } elseif (is_search() && !in_array('search', $templates)) { $output = '<li>' . $this->set_opt('search') . get_search_query() . '</li>'; } elseif (is_page() && !$post->post_parent && !in_array('page', $templates)) { $output = '<li>' . get_the_title() . '</li>'; } elseif (is_page() && $post->post_parent && !in_array('page', $templates)) { $output = $this->is_page_n_has_parent(); } elseif (is_author() && !in_array('author', $templates)) { global $author; $user_info = get_userdata($author); $output = '<li>' . $this->set_opt('author') . $user_info->display_name . '</li>'; } elseif (is_404() && !in_array('404', $templates)) { $output = '<li>' . $this->set_opt('error') . '</li>'; } else { //All other cases no Breadcrumb trail. } } if (!empty($output)) { $return = '<ul class="breadcrumb">'; $return .= $this->set_opt('el_prefix'); $return .= $output; $return .= '</ul>'; echo $return; } }
/** * Creates the breadcrumbs HTML * * @param string $separator , separator symbol that will be set between elements * * @return string */ public function render($separator = ">") { $data = array('labels' => array()); $settings['labels']['homepage-title'] = fw_get_db_ext_settings_option($this->get_name(), 'homepage-title'); $settings['labels']['blogpage-title'] = fw_get_db_ext_settings_option($this->get_name(), 'blogpage-title'); $settings['labels']['404-title'] = fw_get_db_ext_settings_option($this->get_name(), '404-title'); $breadcrumbs = new Breadcrumbs_Builder($settings); $data['items'] = $breadcrumbs->get_breadcrumbs(); $data['separator'] = $separator; return $this->render_view('breadcrumbs', $data); }
/** * @param $options_before_save */ public function _action_fw_ext_social_facebook_save_options($options_before_save) { $parent = $this->get_parent()->get_name(); $response = wp_remote_get(add_query_arg(array('grant_type' => 'client_credentials', 'client_id' => fw_get_db_ext_settings_option($parent, 'facebook-app-id'), 'client_secret' => fw_get_db_ext_settings_option($parent, 'facebook-app-secret')), 'https://graph.facebook.com/oauth/access_token')); $body = wp_remote_retrieve_body($response); if (strpos($body, 'access_token=') !== false) { $token = substr($body, 13); fw_set_db_extension_data($this->get_name(), $this->access_token_name, $token); } else { fw_set_db_extension_data($this->get_name(), $this->access_token_name, false); } }
/** * Adds webmasters meta tags in front-end * @internal */ public function _theme_action_add_webmasters_meta() { $webmasters = $this->get_config('webmasters'); foreach ($webmasters as $webmaster) { if (!isset($this->webmasters[$webmaster])) { continue; } $data = array(); $value = fw_get_db_ext_settings_option($this->get_parent()->get_name(), $this->get_name() . '-' . $webmaster); if (empty($value)) { continue; } $data['name'] = $this->webmasters[$webmaster]['settings']['meta-name']; $data['content'] = $value; echo $this->render_view('meta', $data); } }
public function ns_init() { $taxonomies = get_taxonomies(); if (is_array($taxonomies)) { $excluded_taxonomies = array_keys(fw_get_db_ext_settings_option('ns-category-features', 'excluded_taxonomies', array())); if (empty($excluded_taxonomies)) { $excluded_taxonomies = array(); } foreach ($taxonomies as $ns_taxonomy) { if (in_array($ns_taxonomy, $excluded_taxonomies)) { continue; } add_action($ns_taxonomy . '_add_form_fields', array($this, 'ns_add_texonomy_field')); add_action($ns_taxonomy . '_edit_form_fields', array($this, 'ns_edit_texonomy_field')); add_filter('manage_edit-' . $ns_taxonomy . '_columns', array($this, 'ns_taxonomy_columns')); add_filter('manage_' . $ns_taxonomy . '_custom_column', array($this, 'ns_taxonomy_column'), 10, 3); } } }
/** * @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; }
/** * Get extension's settings option value from the database * * @param string|null $option_id * @param null|mixed $default_value If no option found in the database, this value will be returned * @param null|bool $get_original_value Original value is that with no translations and other changes * * @return mixed|null */ public final function get_db_settings_option($option_id = null, $default_value = null, $get_original_value = null) { return fw_get_db_ext_settings_option($this->get_name(), $option_id, $default_value, $get_original_value); }
private function get_settings_option($id) { return fw_get_db_ext_settings_option($this->get_parent()->get_name(), $id); }
/** * @return string */ public function get_analytics_code() { return fw_get_db_ext_settings_option($this->get_name(), 'code'); }
/** * Returns a instance of TwitterOAuth (see: https://github.com/abraham/twitteroauth), based on keys inserted into the page Social * @return TwitterOAuth */ public function get_connection() { require_once $this->get_declared_path() . '/includes/twitteroauth.php'; $parent = $this->get_parent()->get_name(); return new TwitterOAuth(fw_get_db_ext_settings_option($parent, 'twitter-consumer-key'), fw_get_db_ext_settings_option($parent, 'twitter-consumer-secret'), fw_get_db_ext_settings_option($parent, 'twitter-access-token'), fw_get_db_ext_settings_option($parent, 'twitter-access-token-secret')); }
/** * Convert data to default language */ public function convert_data_to_default_language() { $convert = fw_get_db_ext_settings_option($this->get_name(), 'convert'); if ($convert) { $this->get_child('translate-menus')->convert_to_default_language(); $this->get_child('translate-terms')->convert_to_default_language(); $this->get_child('translate-posts')->convert_to_default_language(); $this->get_child('translate-widgets')->convert_to_default_language(); } }
/** * Init the titles-metas extension in frontend * This method get the location ( posts, pages, archives, taxonomies ) SEO titles and returns to the wp_title * * @param $title , current wordpress title, before being processed * @param $sep , worpdress title separator * @param $sepdirection , wordpress separator direction * * @return string * @internal */ public function _action_add_title($title, $sep, $sepdirection) { $location = $this->get_parent()->get_location(); $prefix = $this->get_name() . '-'; if (empty($location['type'])) { // fixme: investigate why this happens and add an info comment here return; } switch ($location['type']) { case '404': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'not-found-title')); if (!empty($fw_title)) { $title = $fw_title; } break; case 'search': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'search-page-title')); if (!empty($fw_title)) { $title = $fw_title; } break; case 'author_archive': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'author-archive-title')); if (!empty($fw_title)) { $title = $fw_title; } break; case 'date_archive': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'date-archive-title')); if (!empty($fw_title)) { $title = $fw_title; } break; case 'front_page': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'homepage-title')); if (!empty($fw_title)) { $title = $fw_title; } elseif (isset($location['id'])) { $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_post_option($location['id'], $prefix . 'title')); if (!empty($fw_title)) { $title = $fw_title; } } break; case 'blog_page': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_post_option($location['id'], $prefix . 'title')); if (!empty($fw_title)) { $title = $fw_title; } break; case 'singular': if (!in_array($location['post_type'], $this->allowed_post_types)) { break; } $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_post_option($location['id'], $prefix . 'title')); if (empty($fw_title)) { $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . $location['post_type'] . '-title')); } if (!empty($fw_title)) { $title = $fw_title; } break; case 'category': if (!in_array($location['type'], $this->allowed_taxonomies)) { break; } $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_term_option($location['id'], 'category', $prefix . 'title')); if (empty($fw_title)) { $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'category-title')); } if (!empty($fw_title)) { $title = $fw_title; } break; case 'tag': if (!in_array('post_tag', $this->allowed_taxonomies)) { break; } $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_term_option($location['id'], 'post_tag', $prefix . 'title')); if (empty($fw_title)) { $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'post_tag-title')); } if (!empty($fw_title)) { $title = $fw_title; } break; case 'taxonomy': if (!in_array($location['taxonomy_type'], $this->allowed_taxonomies)) { break; } $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_term_option($location['id'], $location['taxonomy_type'], $prefix . 'title')); if (empty($fw_title)) { $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . $location['taxonomy_type'] . '-title')); } if (!empty($fw_title)) { $title = $fw_title; } break; case 'feed': $fw_title = fw_ext_seo_parse_meta_tags(fw_get_db_ext_settings_option($this->get_parent()->get_name(), $prefix . 'homepage-title')); if (!empty($fw_title)) { $title = $fw_title; } break; } $title = apply_filters('fw_ext_seo_titles_metas_load_title', $title, $sep, $sepdirection, $location); return $title; }