__( 'General Plugin Settings', WPRSS_TEXT_DOMAIN ),
'custom_feed' => __( 'Create a Custom RSS Feed', WPRSS_TEXT_DOMAIN ),
'advanced' => __( 'Advanced Settings', WPRSS_TEXT_DOMAIN ),
'styles' => __( 'Styles', WPRSS_TEXT_DOMAIN ),
)
);
// Define the settings per section
$settings = apply_filters(
'wprss_settings_array',
array(
'general' => array(
'limit-feed-items-by-age' => array(
'label' => __( 'Limit feed items stored by age', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_limit_feed_items_age_callback'
),
'limit-feed-items-imported' => array(
'label' => __( 'Limit feed items stored per feed', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_limit_feed_items_imported_callback'
),
'limit-feed-items-db' => array(
'label' => __( 'Limit feed items stored', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_limit_feed_items_callback'
),
'limit_feed_items_per_import' => array(
'label' => __( 'Limit feed items per import', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_limit_feed_items_per_import_callback'
),
'feed_items_import_order' => array(
'label' => __( 'Import order', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_feed_items_import_order_callback'
),
'cron-interval' => array(
'label' => __( 'Feed processing interval', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_cron_interval_callback'
),
'unique-titles' => array(
'label' => __( 'Unique titles only', WPRSS_TEXT_DOMAIN),
'callback' => 'wprss_setting_unique_titles'
),
),
'custom_feed' => array(
'custom-feed-url' => array(
'label' => __( 'Custom feed URL', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_settings_custom_feed_url_callback'
),
'custom-feed-title' => array(
'label' => __( 'Custom feed title', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_settings_custom_feed_title_callback'
),
'custom-feed-limit' => array(
'label' => __( 'Custom feed limit', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_settings_custom_feed_limit_callback'
),
),
)
);
$settings['styles'] = array(
'styles-disable' => array(
'label' => __( 'Disable Styles', WPRSS_TEXT_DOMAIN ),
'callback' => 'wprss_setting_styles_disable_callback'
)
);
if ( apply_filters( 'wprss_use_fixed_feed_limit', FALSE ) === FALSE ) {
unset( $settings['general']['limit-feed-items-db'] );
}
$setting_field_id_prefix = 'wprss-settings-';
// Loop through each setting field and register it
foreach( $settings as $section => $fields ) {
if ( count( $fields ) === 0 ) {
continue;
}
add_settings_section(
"wprss_settings_${section}_section",
$sections[ $section ],
"wprss_settings_${section}_callback",
'wprss_settings_general'
);
foreach ( $fields as $id => $data ) {
/**
* This will be passed to the field callback as the only argument
* @see http://codex.wordpress.org/Function_Reference/add_settings_field#Parameters
*/
$callback_args = array(
'field_id' => $id,
'field_id_prefix' => $setting_field_id_prefix,
'section_id' => $section,
'field_label' => isset( $data['label'] ) ? $data['label'] : null,
'tooltip' => isset( $data['tooltip'] ) ? $data['tooltip'] : null
);
add_settings_field(
$setting_field_id_prefix . $id,
$data['label'],
$data['callback'],
'wprss_settings_general',
"wprss_settings_${section}_section",
$callback_args
);
}
}
// If user requested to download system info, generate the download.
if ( isset( $_POST['wprss-sysinfo'] ) ) {
do_action('wprss_download_sysinfo');
}
do_action( 'wprss_admin_init' );
}
/**
* Returns the HTML of a tooltip handle.
*
* Filters used:
* - `wprss_settings_inline_help_default_options` - The default options for "Settings" page's tooltips
* - `wprss_settings_inline_help_id_prefix` - The prefix for all tooltip IDs for the "Settings" page.
*
* @param string $id The ID of the tooltip
* @param string|null $text Text for this tooltip, if any.
* @param array $options Any options for this setting.
* @return string Tooltip handle HTML. See {@link WPRSS_Help::tooltip()}.
*/
function wprss_settings_inline_help( $id, $text = null, $options = array() ) {
$help = WPRSS_Help::get_instance();
// Default options, entry point
$defaults = apply_filters( 'wprss_settings_inline_help_default_options', array(
'tooltip_handle_class_extra' => $help->get_options('tooltip_handle_class_extra') . ' ' . $help->get_options('tooltip_handle_class') . '-setting'
));
$options = $help->array_merge_recursive_distinct( $defaults, $options );
// ID Prefix
$id = apply_filters( 'wprss_settings_inline_help_id_prefix', 'setting-' ) . $id;
return $help->tooltip( $id, $text, $options );
}
/**
*
* @param type $string
* @return type
*/
function wprss_settings_field_name_prefix( $string = '' ) {
$string = (string) $string;
$prefix = apply_filters( 'wprss_settings_field_name_prefix', 'wprss_settings_', $string );
return $prefix . $string;
}
/**
* Generates a uniform setting field name for use in HTML.
* The parts used are the ID of the field, the section it is in, and an optional prefix.
* All parts are optional, but, if they appear, they shall appear in this order: $prefix, $section, $id.
*
* If only the section is not specified, the $id will be simply prefixed by $prefix.
* If either the $id or the $section are empty (but not both), $prefix will be stripped of known separators.
* Empty parts will be excluded.
*
* @param string $id ID of the field.
* @param string|null $section Name of the section, to which this field belongs.
* @param string|null $prefix The string to prefix the name with; appears first. If boolean false, no prefix will be applied. Default: return value of {@link wprss_settings_field_name_prefix()}.
* @return string Name of the settings field, namespaced and optionally prefixed.
*/
function wprss_settings_field_name( $id = null, $section = null, $prefix = null ) {
if( $prefix !== false ) $prefix = is_null( $prefix ) ? wprss_settings_field_name_prefix() : $prefix;
else $prefix = '';
$section = (string) $section;
$format = '';
if( !strlen( $section ) xor !strlen($id) ) $prefix = trim ( $prefix, "\t\n\r _-:" );
if( strlen( $prefix ) ) $format .= '%3$s';
if( strlen( $section ) ) $format .= '%2$s';
if( strlen( $id ) ) $format .= ( !strlen( $section ) ? '%1$s' : '[%1$s]' );
return apply_filters( 'wprss_settings_field_name', sprintf( $format, $id, $section, $prefix ), $id, $section, $prefix );
}
/**
* Build the plugin settings page, used to save general settings like whether a link should be follow or no follow
* @since 1.1
*/
function wprss_settings_page_display() {
$etText = wprss_is_et_active() ? '
' . sprintf(__('Wondering how Templates work with Excerpts & Thumbnails? Click here to learn more.', WPRSS_TEXT_DOMAIN), 'https://kb.wprssaggregator.com/article/459-using-excerpts-thumbnails-with-templates') : '';
wprss_plugin_enqueue_app_scripts('wpra-settings', WPRSS_APP_JS . 'settings.min.js');
wp_enqueue_style('wpra-settings', WPRSS_APP_CSS . 'common.min.css');
wp_localize_script('wpra-settings', 'WpraSettings', [
'notice' => [
'id' => 'settings-notice',
'visible' => !wprss_is_new_user(),
'title' => __('The display options for WP RSS Aggregator have now become Templates.', WPRSS_TEXT_DOMAIN),
'body' => __('As of Core version 4.13, we have introduced the concept of templates to replace the'
. ' display settings that were previously available on this page. These templates provide you'
. ' with more flexibility and new designs. They also come with a revamped TinyMCE shortcode button'
. ' for the Classic Editor and a brand new block for those using WP 5.0+ with the Gutenberg block editor.'
. '
'
. 'Go to Templates under RSS Aggregator to set up your templates. Please note that the default '
. 'template you will see there is set up using your pre-existing display options, nothing is lost or changed.', WPRSS_TEXT_DOMAIN) . $etText,
'learnMore' => 'https://www.wprssaggregator.com/core-version-4-13-celebrating-one-million-downloads/'
]
])
?>
You use this code by adding any of the following to any URL on your site.', WPRSS_TEXT_DOMAIN ) ?>
/> __('On', WPRSS_TEXT_DOMAIN), 0 => __('Off', WPRSS_TEXT_DOMAIN), -1 => __('Default', WPRSS_TEXT_DOMAIN), ); } /** * Renders a