vars = $vars; $this->base_path = $base_path; $this->slug = $slug; $this->plugin_name = $plugin_name; $this->capability = $capability; $this->icon = $icon; $this->position = $position; $this->tabs = $tabs; if ( $active_tab ) { $this->set_active_tab( $active_tab ); } else { $this->set_active_tab( $tabs[0]['slug'] ); } $this->settings = $settings; $this->option_name = $option_name; $this->false_fields = array(); $this->textarea_fields = array(); $this->display_your_feed_sections = array(); } public function get_vars() { return $this->vars; } public function get_option_name() { return $this->option_name; } public function verify_post( $post ) { return wp_verify_nonce( $post[ $this->option_name . '_validate' ], $this->option_name . '_validate' ); } public function hidden_fields_for_tab( $tab ) { wp_nonce_field( $this->get_option_name() . '_validate', $this->get_option_name() . '_validate', true, true ); ?> 'sbspf_types', 'tab' => 'configure', 'save_after' => 'true' ); $this->add_settings_section( $args ); /* Types */ $locator_html = ''; if ( Feed_Locator::count_unique() > -1 ) { $locator_html .= ''; } $args = array( 'name' => 'type', 'section' => 'sbspf_types', 'callback' => 'types', 'title' => '', 'shortcode' => array( 'key' => 'type', 'example' => 'channel', 'description' => __( 'Type of feed to display', 'feeds-for-youtube' ) . ' e.g. channel, playlist, search, favorites, live', 'after_description' => $locator_html, 'display_section' => 'configure' ), 'types' => $this->types ); $this->add_settings_field( $args ); /* Cache */ $args = array( 'name' => 'cache', 'section' => 'sbspf_types', 'callback' => 'cache', 'title' => __( 'Check for new posts', 'feeds-for-youtube' ) ); $this->add_settings_field( $args ); /** * Customize Tab */ $args = array( 'title' => __( 'General', 'feeds-for-youtube' ), 'id' => 'sbspf_general', 'tab' => 'customize', 'save_after' => 'true' ); $this->add_settings_section( $args ); /* Width and Height */ $select_options = array( array( 'label' => '%', 'value' => '%' ), array( 'label' => 'px', 'value' => 'px' ) ); $args = array( 'name' => 'width', 'default' => '100', 'section' => 'sbspf_general', 'callback' => 'text', 'min' => 1, 'size' => 4, 'title' => __( 'Width of Feed', 'feeds-for-youtube' ), 'shortcode' => array( 'key' => 'width', 'example' => '300px', 'description' => __( 'The width of your feed. Any number with a unit like "px" or "%".', 'feeds-for-youtube' ), 'display_section' => 'customize' ), 'select_name' => 'widthunit', 'select_options' => $select_options, 'hidden' => array( 'callback' => 'checkbox', 'name' => 'width_responsive', 'label' => __( 'Set to be 100% width on mobile?', 'feeds-for-youtube' ), 'before' => '
', 'after' => '
', 'tooltip_info' => __( 'If you set a width on the feed then this will be used on mobile as well as desktop. Check this setting to set the feed width to be 100% on mobile so that it is responsive.', 'feeds-for-youtube' ) ), ); $this->add_settings_field( $args ); $select_options = array( array( 'label' => '%', 'value' => '%' ), array( 'label' => 'px', 'value' => 'px' ) ); $args = array( 'name' => 'height', 'default' => '', 'section' => 'sbspf_general', 'callback' => 'text', 'min' => 1, 'size' => 4, 'title' => __( 'Height of Feed', 'feeds-for-youtube' ), 'shortcode' => array( 'key' => 'height', 'example' => '500px', 'description' => __( 'The height of your feed. Any number with a unit like "px" or "em".', 'feeds-for-youtube' ), 'display_section' => 'customize' ), 'select_name' => 'heightunit', 'select_options' => $select_options, ); $this->add_settings_field( $args ); $args = array( 'name' => 'background', 'default' => '', 'section' => 'sbspf_general', 'callback' => 'color', 'title' => __( 'Background Color', 'feeds-for-youtube' ), 'shortcode' => array( 'key' => 'background', 'example' => '#f00', 'description' => __( 'Background color for the feed. Any hex color code.', 'feeds-for-youtube' ), 'display_section' => 'customize' ), ); $this->add_settings_field( $args ); $args = array( 'title' => __( 'Layout', 'feeds-for-youtube' ), 'id' => 'sbspf_layout', 'tab' => 'customize', 'save_after' => 'true' ); $this->add_settings_section( $args ); $args = array( 'name' => 'layout', 'section' => 'sbspf_layout', 'callback' => 'layout', 'title' => __( 'Layout Type', 'feeds-for-youtube' ), 'layouts' => $this->layouts, 'shortcode' => array( 'key' => 'layout', 'example' => 'list', 'description' => __( 'How your posts are display visually.', 'feeds-for-youtube' ), 'display_section' => 'layout' ) ); $this->add_settings_field( $args ); } public function additional_settings_init() { } public function add_false_field( $name, $tab ) { $this->false_fields[ $tab ][] = $name; } public function get_false_fields( $tab ) { if ( isset( $this->false_fields[ $tab ] ) ) { return $this->false_fields[ $tab ]; } return array(); } public function add_textarea_field( $name, $tab ) { $this->textarea_fields[ $tab ][] = $name; } public function get_textarea_fields( $tab ) { if ( isset( $this->textarea_fields[ $tab ] ) ) { return $this->textarea_fields[ $tab ]; } return array(); } public function blank() { } public function add_settings_section( $args ) { $title = isset( $args['title'] ) ? $args['title'] : ''; $callback = isset( $args['callback'] ) ? $args['callback'] : array( $this, 'blank' ); add_settings_section( $args['id'], $title, $callback, $args['id'] ); $save_after = isset( $args['save_after'] ) ? $args['save_after'] : false; $this->settings_sections[ $args['tab'] ][] = array( 'id' => $args['id'], 'save_after' => $save_after ); } public function add_settings_field( $args ) { $title_after = ''; $shortcode = false; if ( isset( $args['shortcode'] ) ) { $title_after = isset( $args['shortcode']['after'] ) ? $args['shortcode']['after'] : ''; $shortcode = $args['shortcode']; } if ( $shortcode ) { $this->display_your_feed_sections[ $shortcode['display_section'] ]['settings'][] = $shortcode; } if ( $args['callback'] === 'types' ) { $formatted_label = ''; $formatted_label .= 'type'. "\n"; foreach ( $args['types'] as $type ) { $shortcode = array( 'key' => $type['slug'], 'example' => $type['example'], 'description' => $type['description'], 'display_section' => 'configure' ); $this->display_your_feed_sections[ $shortcode['display_section'] ]['settings'][] = $shortcode; $formatted_label .= 'Eg: type=' . $type['slug'] . '
'; $formatted_label .= $type['slug'] . '="' . substr( $type['example'], 0, 14) . '"
'; } $formatted_label .= '

'; if ( isset( $args['shortcode']['after_description'] ) ) { $formatted_label .= $args['shortcode']['after_description']; } $title = $formatted_label; } else { $title = $this->format_title( $args['title'], $args['name'], $shortcode, $title_after ); } if ( $args['callback'] === 'checkbox' || (isset( $args['falsefield'] ) && $args['falsefield'] === true) ) { $tab = 'none'; foreach ( $this->settings_sections as $key => $settings_sections ) { foreach ( $settings_sections as $this_tab_sections ) { if ( $this_tab_sections['id'] === $args['section'] ) { $tab = $key; } } } $this->add_false_field( $args['name'], $tab ); } if ( $args['callback'] === 'layout' || $args['callback'] === 'sub_option' ) { $tab = 'none'; foreach ( $this->settings_sections as $key => $settings_sections ) { foreach ( $settings_sections as $this_tab_sections ) { if ( $this_tab_sections['id'] === $args['section'] ) { $tab = $key; } } } $sub_options = isset( $args['layouts'] ) ? $args['layouts'] : $args['sub_options']; foreach ( $sub_options as $sub_option ) { if ( isset( $sub_option['options'] ) ) { foreach( $sub_option['options'] as $sub_sub_option ) { if ( ! empty( $sub_sub_option['shortcode'] ) ) { $key = ! empty( $sub_sub_option['shortcode']['key'] ) ? $sub_sub_option['shortcode']['key'] : $sub_option['slug'] . $sub_sub_option['name']; $example = ! empty( $sub_sub_option['shortcode']['example'] ) ? $sub_sub_option['shortcode']['example'] : ''; $description = ! empty( $sub_sub_option['shortcode']['description'] ) ? $sub_sub_option['shortcode']['description'] : ''; $display_section = ! empty( $sub_sub_option['shortcode']['display_section'] ) ? $sub_sub_option['shortcode']['display_section'] : str_replace( 'sbspf_', '', $args['section'] ); $sub_shortcode = array( 'key' => $key, 'example' => $example, 'description' => $description, 'display_section' => $display_section ); if ( isset( $this->display_your_feed_sections[ $display_section ] ) ) { $this->display_your_feed_sections[ $display_section ]['settings'][] = $sub_shortcode; } } if ( $sub_sub_option['callback'] === 'checkbox' ) { $this->add_false_field( $sub_option['slug'] . $sub_sub_option['name'], $tab ); } } } } } if ( $args['callback'] === 'textarea' ) { $tab = 'none'; foreach ( $this->settings_sections as $key => $settings_sections ) { foreach ( $settings_sections as $this_tab_sections ) { if ( $this_tab_sections['id'] === $args['section'] ) { $tab = $key; } } } $this->add_textarea_field( $args['name'], $tab ); } add_settings_field( $args['name'], $title, array( $this, $args['callback'] ), $args['section'], $args['section'], $args ); if ( isset( $args['hidden'] ) ) { if ( $args['hidden']['callback'] === 'checkbox' ) { $tab = 'none'; foreach ( $this->settings_sections as $key => $settings_sections ) { foreach ( $settings_sections as $this_tab_sections ) { if ( $this_tab_sections['id'] === $args['section'] ) { $tab = $key; } } } $this->add_false_field( $args['hidden']['name'], $tab ); } } } public function set_feed_types( $types ) { $this->types = $types; } public function set_feed_layouts( $layouts ) { $this->layouts = $layouts; } public function set_display_table_sections( $headings ) { foreach ( $headings as $heading ) { $this->display_your_feed_sections[ $heading['slug'] ] = array( 'label' => $heading['label'], 'settings' => array() ); } } public function checkbox( $args ) { $default = isset( $args['default'] ) ? $args['default'] : false; $selected = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default; $label = isset( $args['label'] ) ? $args['label'] : __( 'Yes' ); $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text(); $has_shortcode = isset( $args['has_shortcode'] ) && $args['has_shortcode'] ? '1' : ''; ?> /> Eg: =

settings[ $args['name'] ] ) ? (array)$this->settings[ $args['name'] ] : (array)$default; $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text(); $index = 0; ?>
/>

settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default; $size = ( isset( $args['size'] ) ) ? ' size="'. $args['size'].'"' : ''; $class = isset( $args['class'] ) ? ' class="'. esc_attr( $args['class'] ) . '"' : ''; $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text(); if ( isset( $args['min'] ) ) : $min = ( isset( $args['min'] ) ) ? ' min="'. $args['min'].'"' : ''; $max = ( isset( $args['max'] ) ) ? ' max="'. $args['max'].'"' : ''; $step = ( isset( $args['step'] ) ) ? ' step="'. $args['step'].'"' : ''; $class = isset( $args['class'] ) ? ' class="sbspf_number_field sbspf_size_' . $args['size'] . ' '. esc_attr( $args['class'] ) . '"' : ' class="sbspf_number_field sbspf_size_' . $args['size'] . '"'; ?> type="number" value="" /> type="text" value="" /> settings[ $args['select_name'] ] ) ? $this->settings[ $args['select_name'] ] : $args['select_options'][0]['value']; ?>

settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default; if ( isset( $args['min'] ) && isset( $args['max'] ) && ((int)$args['min'] < (int)$args['max']) && empty( $args['options'] ) ) { $args['options'] = array(); $i = (int)$args['min']; while ( $i <= (int)$args['max'] ) { $args['options'][] = array( 'label' => $i, 'value' => $i ); $i++; } } $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text(); ?>

settings[ $args['name'] ] ) ? stripslashes( $this->settings[ $args['name'] ] ) : $default; if ( isset( $args['tooltip_info'] ) ) : ?>

text( $args ); } public function types( $args ) { $type_selected = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $args['types'][0]['slug']; foreach ( $args['types'] as $type ) : $input_type = isset( $type['input_type'] ) ? $type['input_type'] : 'connected_account'; $selected = ! empty( $this->settings[ $type['slug'] ] ) ? $this->settings[ $type['slug'] ] : $type['default']; if ( $input_type === 'connected_account' ) { $selected = isset( $this->settings[ $type['slug'] . '_ids' ] ) ? $this->settings[ $type['slug'] . '_ids' ] : array(); } $on_select = isset( $type['onselect'] ) ? $type['onselect'] : false; ?>
>
> get_connected_accounts(); ?>


settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : 'related'; $cta_options = $args['sub_options']; ?>
>
   
Eg: =

vars->social_network(); $type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page'; $caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1; $cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours'; $cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : ''; $cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : ''; $cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : ''; ?>
> default_tooltip_text() ?>


1. When the page loads
Selecting this option means that when the cache expires then the plugin will check %s for new posts the next time that the feed is loaded. You can choose how long this data should be cached for with a minimum time of 15 minutes. If you set the time to 60 minutes then the plugin will clear the cached data after that length of time, and the next time the page is viewed it will check for new data. Tip: If you're experiencing an issue with the plugin not updating automatically then try enabling the setting labeled 'Cron Clear Cache' which is located on the 'Customize' tab.

2. In the background
Selecting this option means that the plugin will check for new data in the background so that the feed is updated behind the scenes. You can select at what time and how often the plugin should check for new data using the settings below. Please note that the plugin will initially check for data from YouTube when the page first loads, but then after that will check in the background on the schedule selected - unless the cache is cleared.", 'feeds-for-youtube' ), $social_network, $social_network ); ?>

>
' . __( 'Next check', 'feeds-for-youtube' ) . ': ' . date( $time_format, $sbspf_next_cron_event + sbspf_get_utc_offset() ) . ' (' . $schedule . ') - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', 'feeds-for-youtube' ) . '

'; } else { echo '

' . __( 'Nothing currently scheduled', 'feeds-for-youtube' ) . '

'; } ?>
settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default; ?>
>
   
Eg: =
option_name . '_' . $name . '">' . $label .''; if ( $shortcode_args ) { $formatted_label .= ' ' . $shortcode_args['key'] . "\n"; $formatted_label .= 'Eg: ' . $shortcode_args['key'] . '=' . $shortcode_args['example'] . '
'; } $formatted_label .= $after; return $formatted_label; } public function validate_options( $input, $tab ) { $updated_options = get_option( $this->option_name, array() ); $false_if_empty_keys = $this->get_false_fields( $tab ); $textarea_keys = $this->get_textarea_fields( $tab ); foreach ( $false_if_empty_keys as $false_key ) { $updated_options[ $false_key ] = false; } foreach ( $input as $key => $val ) { if ( 'custom_js' === $key ) { $updated_options[ $key ] = $val; } else if ( in_array( $key, $false_if_empty_keys ) ) { $updated_options[ $key ] = ($val === 'on'); } elseif ( in_array( $key, $textarea_keys ) ) { $updated_options[ $key ] = sanitize_textarea_field( $val ); } elseif ( is_array( $val ) ) { $updated_options[ $key ] = array(); foreach ( $val as $key2 => $val2 ) { $updated_options[ $key ][ $key2 ] = sanitize_text_field( $val2 ); } } else { $updated_options[ $key ] = sanitize_text_field( $val ); } } if ( $tab === 'configure' ) { do_action( $this->option_name . '_after_configure_save', $updated_options ); } return $updated_options; } public function update_options( $new_settings ) { update_option( $this->get_option_name(), $new_settings ); $this->settings = $new_settings; } public function get_sections( $tab ) { if ( isset( $this->settings_sections[ $tab ] ) ) { return $this->settings_sections[ $tab ]; } return array(); } public function set_active_tab( $active_tab ) { foreach ( $this->tabs as $tab ) { if ( $tab['slug'] === $active_tab ) { $this->active_tab = $tab['slug']; } } } public function get_tabs() { return $this->tabs; } public function get_active_tab() { return $this->active_tab; } public function get_slug() { return $this->slug; } public function get_plugin_name() { return $this->plugin_name; } public function get_path( $view ) { return trailingslashit( $this->base_path ) . $view . '.php'; } public function create_options_page() { require_once trailingslashit( $this->base_path ) . 'main.php'; } public function next_step() { $return = array(); $i = 0; foreach ( $this->tabs as $tab ) { if ( $this->active_tab === $tab['slug'] && isset( $tab['next_step_instructions'] ) ) { $next_tab_slug = isset( $this->tabs[ $i + 1 ]['slug'] ) ? $this->tabs[ $i + 1 ]['slug'] : $tab['slug']; $return = array( 'instructions' => $tab['next_step_instructions'], 'next_tab' => $next_tab_slug ); } $i++; } return $return; } public function get_connected_accounts() { global $sbspf_settings; if ( isset( $sbspf_settings['connected_accounts'] ) ) { return $sbspf_settings['connected_accounts']; } return array(); } public static function connect_account( $args ) { global $sbspf_settings; // do connection // random fake data $account_id = time(); $sbspf_settings['connected_accounts'][ $account_id ] = array( 'access_token' => 'at_' . str_shuffle( $account_id ), 'channel_id' => $account_id, 'username' => 'test' . $account_id, 'is_valid' => true, 'last_checked' => time(), 'profile_picture' => $args['profile_picture'] ); update_option( 'sbspf_settings', $sbspf_settings ); return $sbspf_settings['connected_accounts'][ $account_id ]; } public function default_tooltip_text() { return '' . __( 'What does this mean?', 'feeds-for-youtube' ) . '' . sby_admin_icon( 'question-circle' ); } }