$settings ) { add_settings_section( 'mashsb_settings_' . $tab, __return_null(), '__return_false', 'mashsb_settings_' . $tab ); foreach ( $settings as $option ) { $name = isset( $option['name'] ) ? $option['name'] : ''; add_settings_field( 'mashsb_settings[' . $option['id'] . ']', $name, function_exists( 'mashsb_' . $option['type'] . '_callback' ) ? 'mashsb_' . $option['type'] . '_callback' : 'mashsb_missing_callback', 'mashsb_settings_' . $tab, 'mashsb_settings_' . $tab, array( 'id' => isset( $option['id'] ) ? $option['id'] : null, 'desc' => !empty( $option['desc'] ) ? $option['desc'] : '', 'name' => isset( $option['name'] ) ? $option['name'] : null, 'section' => $tab, 'size' => isset( $option['size'] ) ? $option['size'] : null, 'options' => isset( $option['options'] ) ? $option['options'] : '', 'std' => isset( $option['std'] ) ? $option['std'] : '', 'textarea_rows' => isset( $option['textarea_rows'] ) ? $option['textarea_rows'] : '' ) ); } } // Creates our settings in the options table register_setting( 'mashsb_settings', 'mashsb_settings', 'mashsb_settings_sanitize' ); } add_action( 'admin_init', 'mashsb_register_settings' ); /** * Retrieve the array of plugin settings * * @since 1.8 * @return array */ function mashsb_get_registered_settings() { /** * 'Whitelisted' MASHSB settings, filters are provided for each settings * section to allow extensions and other plugins to add their own settings */ $mashsb_settings = array( /** General Settings */ 'general' => apply_filters( 'mashsb_settings_general', array( 'general_header' => array( 'id' => 'general_header', 'name' => '' . __( 'General', 'mashsb' ) . '', 'desc' => __( '', 'mashsb' ), 'type' => 'header' ), 'mashsb_sharemethod' => array( 'id' => 'mashsb_sharemethod', 'name' => __( 'Share Count', 'mashsb' ), 'desc' => __( '- SharedCount.com is a third party service free for up to 500 daily requests. It collects shares for Facebook.

Twitter count is aggreagated via https://opensharecount.com. You must sign up with your Twitter account for this free service to get the twitter share count. Visit the site https://opensharecount.com, fill in your website domain and click on Sign up.

Note: You need MashShare Social Network Add-On for enabling Twitter count.', 'mashsb' ), 'type' => 'select', 'options' => array( 'sharedcount' => 'Sharedcount.com' ) ), 'mashsharer_apikey' => array( 'id' => 'mashsharer_apikey', 'name' => __( 'Sharedcount.com API Key', 'mashsb' ), 'desc' => __( 'This is needed to use the sharedcount.com Share Count method. Get it at SharedCount.com for 500 free daily requests.', 'mashsb' ), 'type' => 'text', 'size' => 'medium' ), 'caching_method' => array( 'id' => 'caching_method', 'name' => __( 'Caching Method', 'mashsb' ), 'desc' => sprintf(__( 'Async Cache Refresh
Refreshes the cache asyncronously in the background.

- New posts are updated at each hour.
- Posts older than 3 weeks are updated every 4 hours
- Post older than 2 months are updated every 12 hours

Refresh while loading
Rebuilds expired cache while page is loaded after cache expiration time.

If shares are not updating or site is heavy cached activate Refresh while loading!
That\'s the default method.
Shares still not shown? Read this first!', 'mashsb' ), 'http://docs.mashshare.net/article/4-try-this-first-before-troubleshooting'), 'type' => 'select', 'options' => array( 'async_cache' => 'Async Cache Refresh', 'refresh_loading' => 'Refresh while loading' ) ), 'mashsharer_cache' => array( 'id' => 'mashsharer_cache', 'name' => __( 'Cache expiration', 'mashsb' ), 'desc' => __( 'Shares are counted for posts after a certain time and counts are not updated immediately. Sharedcount.com uses his own cache (30 - 60min).

Default: 5 min. Recommended: 30min and more', 'mashsb' ), 'type' => 'select', 'options' => mashsb_get_expiretimes() ), 'facebook_count' => array( 'id' => 'facebook_count_mode', 'name' => __( 'Facebook Count', 'mashsb' ), 'desc' => __( 'Get the Facebook total count including "likes" and "shares" or get only the pure share count', 'mashsb' ), 'type' => 'select', 'options' => array( 'shares' => 'Shares', 'total' => 'Shares + Comments' ) ), 'cumulate_http_https' => array( 'id' => 'cumulate_http_https', 'name' => __( 'Cumulate Http(s) Shares', 'mashsb' ), 'desc' => __( 'Activate this if you want facebook shares to be cumulated for https and http scheme. If you switched your site to from http to https this is needed to not loose any previous shares which are cumulated earlier for the non ssl version of your site. If you are not missing any shares do not activate this option.', 'mashsb' ), 'type' => 'checkbox' ), 'fake_count' => array( 'id' => 'fake_count', 'name' => __( 'Fake Share Count', 'mashsb' ), 'desc' => __( 'This number will be aggregated to all your share counts and is multiplied with a post specific factor. (Number of words of post title divided with 10).', 'mashsb' ), 'type' => 'text', 'size' => 'medium' ), 'disable_sharecount' => array( 'id' => 'disable_sharecount', 'name' => __( 'Disable Sharecount', 'mashsb' ), 'desc' => __( 'Use this if share should not be counted. Default: false', 'mashsb' ), 'type' => 'checkbox' ), 'hide_sharecount' => array( 'id' => 'hide_sharecount', 'name' => __( 'Hide Sharecount', 'mashsb' ), 'desc' => __( 'Optional: If you fill in any number here, the shares for a specific post are not shown until the share count of this number is reached.', 'mashsb' ), 'type' => 'text', 'size' => 'small' ), 'execution_order' => array( 'id' => 'execution_order', 'name' => __( 'Execution Order', 'mashsb' ), 'desc' => __( 'If you use other content plugins you can define here the execution order. Lower numbers mean earlier execution. E.g. Say "0" and Mashshare is executed before any other plugin (When the other plugin is not overwriting our execution order). Default is "1000"', 'mashsb' ), 'type' => 'text', 'size' => 'small', 'std' => 1000 ), 'load_scripts_footer' => array( 'id' => 'load_scripts_footer', 'name' => __( 'JavaScript in Footer', 'mashsb' ), 'desc' => __( 'Enable this to load all *.js files into footer. Make sure your theme uses the wp_footer() template tag in the appropriate place. Default: Disabled', 'mashsb' ), 'type' => 'checkbox' ), 'loadall' => array( 'id' => 'loadall', 'name' => __( 'JS & CSS Everywhere', 'mashsb' ), 'desc' => __( 'Enable this option if you are using
<?php echo do_shortcode("[mashshare]"); ?> to make sure that all css and js files are loaded. If Top or Bottom automatic position is used you can deactivate this option to allow conditional loading so MashShare\'s JS and CSS files are loaded only on pages where MashShare is used.', 'mashsb' ), 'type' => 'checkbox', 'std' => 'false' ), 'twitter_popup' => array( 'id' => 'twitter_popup', 'name' => __( 'Twitter Popup disabled', 'mashsb' ), 'desc' => __( 'Check this box if your twitter popup is openening twice. This happens sometimes when you are using any third party twitter plugin or the twitter SDK on your website.', 'mashsb' ), 'type' => 'checkbox', 'std' => '0' ), 'uninstall_on_delete' => array( 'id' => 'uninstall_on_delete', 'name' => __( 'Remove Data on Uninstall?', 'mashsb' ), 'desc' => __( 'Check this box if you would like Mashshare to completely remove all of its data when the plugin is deleted.', 'mashsb' ), 'type' => 'checkbox' ), 'allow_tracking' => array( 'id' => 'allow_tracking', 'name' => __( 'Allow Usage Tracking', 'mashsb' ), 'desc' => sprintf( __( 'Allow Mashshare to track plugin usage? Opt-in to tracking and our newsletter and immediately be emailed a 20%% discount to the Mashshare shop, valid towards the purchase of Add-Ons. No sensitive data is tracked.', 'mashsb' ), 'https://www.mashshare.net/add-ons/?utm_source=' . substr( md5( get_bloginfo( 'name' ) ), 0, 10 ) . '&utm_medium=admin&utm_term=setting&utm_campaign=MASHSBUsageTracking' ), 'type' => 'checkbox' ), 'is_main_query' => array( 'id' => 'is_main_query', 'name' => __( 'Hide Buttons in Widgets (is_main_query)', 'mashsb' ), 'desc' => __( 'If Share Buttons are shown in widgets enable this option. For devs: This uses the is_main_query condition. ' ) , 'type' => 'checkbox' ), "user_roles_for_sharing_options" => array( "id" => "user_roles_for_sharing_options", "name" => __("Show Share Options Meta Box User Roles", "mashsb"), "desc" => __("Show the MashShare Share Options Meta Box on the page editor for certain user roles only. If nothing is set meta box is shown to all user roles.", "mashsb"), "type" => "multiselect", "options" => array_merge(array('disable' => 'Disable Share Options Meta Box') , mashsb_get_user_roles()), "placeholder" => __("Select User Roles", "mashsb"), "std" => __("All Roles", "mashsb"), ), 'services_header' => array( 'id' => 'services_header', 'name' => '' . __( 'Networks', 'mashsb' ) . '', 'desc' => '', 'type' => 'header' ), array( 'id' => 'fb_publisher_url', 'name' => __( 'Facebook page url', 'mashsb' ), 'desc' => __( 'Optional: The url of the main facebook account connected with this site', 'mashsb' ), 'type' => 'text', 'size' => 'large' ), 'mashsharer_hashtag' => array( 'id' => 'mashsharer_hashtag', 'name' => __( 'Twitter Username', 'mashsb' ), 'desc' => __( 'Optional: Using your twitter username results in via @username', 'mashsb' ), 'type' => 'text', 'size' => 'medium' ), 'twitter_card' => array( 'id' => 'twitter_card', 'name' => __( 'Twitter Card', 'mashsb' ), 'desc' => __( 'If this is activated MashShare is creating new tags in head of your site for twitter card data and populates them with data coming from the MashShare Twitter Meta Box from the post editing screen or in case you are using Yoast these fields will be populated with the Yoast Twitter Card Data.

So the MashShare twitter card tags will be containing the same social meta data that YOAST would be supplying on your site. So you can use that feature parallel to the Yoast twitter card integration and you do not need to deactivate it even when you prefer to use the Yoast Twitter Card editor.', 'mashsb' ), 'type' => 'checkbox' ), 'open_graph' => array( 'id' => 'open_graph', 'name' => __( 'Open Graph Meta Tags', 'mashsb' ), 'desc' => __( 'If this is activated MashShare is creating new tags in head of your site for open graph data and populates them with data coming from the MashShare Open Graph Meta Box from the post editing screen or in case you are using Yoast these fields will be populated with the Yoast Open Graph Data.

So the MashShare open graph data will be containing the same social meta data that YOAST would be supplying on your site. So you can use that feature parallel to the Yoast open graph integration and you do not need to deactivate it even when you prefer to use the Yoast Open Graph editor.', 'mashsb' ), 'type' => 'checkbox' ), 'visible_services' => array( 'id' => 'visible_services', 'name' => __( 'Large Buttons', 'mashsb' ), 'desc' => __( 'Specify how many services and social networks are visible before the "Plus" Button is shown. This buttons turn into large prominent buttons.', 'mashsb' ), 'type' => 'select', 'options' => numberServices() ), 'networks' => array( 'id' => 'networks', 'name' => __( 'Social Networks', 'mashsb' ), 'desc' => __( 'Use Drag and drop for sorting. Enable the ones that should be visible. Activate
more networks than number of "Large Buttons" and [+] PLUS button will be
added automatically.', 'mashsb' ), 'type' => 'networks', 'options' => mashsb_get_networks_list() ), 'style_header' => array( 'id' => 'style_header', 'name' => '' . __( 'Visual', 'mashsb' ) . '', 'desc' => __( '', 'mashsb' ), 'type' => 'header' ), 'share_headline' => array( 'id' => 'share_headline', 'name' => __( 'Shares', 'mashsb' ), 'type' => 'headline' ), 'mashsharer_round' => array( 'id' => 'mashsharer_round', 'name' => __( 'Round up Shares', 'mashsb' ), 'desc' => __( 'Share counts greater than 1.000 will be shown as 1k. Greater than 1 Million as 1M', 'mashsb' ), 'type' => 'checkbox' ), 'animate_shares' => array( 'id' => 'animate_shares', 'name' => __( 'Animate Shares', 'mashsb' ), 'desc' => __( 'Count up the shares on page loading with a nice looking animation effect. This only works on singular pages and not with shortcodes generated buttons.', 'mashsb' ), 'type' => 'checkbox' ), 'sharecount_title' => array( 'id' => 'sharecount_title', 'name' => __( 'Share Count Label', 'mashsb' ), 'desc' => __( 'Change the text of the Share count title. Default: SHARES', 'mashsb' ), 'type' => 'text', 'size' => 'medium', 'std' => 'SHARES' ), 'share_color' => array( 'id' => 'share_color', 'name' => __( 'Share Count Color', 'mashsb' ), 'desc' => __( 'Choose color of the share number in hex format, e.g. #7FC04C: ', 'mashsb' ), 'type' => 'color_select', 'size' => 'medium', 'std' => '#cccccc' ), 'button_headline' => array( 'id' => 'button_headline', 'name' => __( 'Buttons', 'mashsb' ), 'type' => 'headline' ), ####################### 'buttons_size' => array( 'id' => 'buttons_size', 'name' => __( 'Buttons Size', 'mashsb' ), 'desc' => __('', 'mashsb'), 'type' => 'select', 'options' => array( 'mash-large' => 'Large', 'mash-medium' => 'Medium', 'mash-small' => 'Small' ), 'std' => 'Large' ), 'responsive_buttons' => array( 'id' => 'responsive_buttons', 'name' => __( 'Full Responsive Buttons', 'mashsb' ), 'desc' => __( 'Get full width buttons on large devices and small buttons on mobile devices. Deactivate to specify manually a fixed button width.', 'mashsb' ), 'type' => 'checkbox' ), array( 'id' => 'button_width', 'name' => __( 'Button Width', 'mashpv' ), 'desc' => __( 'Minimum with of the large share buttons in pixels', 'mashpv' ), 'type' => 'number', 'size' => 'normal', 'std' => '177' ), 'button_margin' => array( 'id' => 'button_margin', 'name' => __( 'Button Margin', 'mashsb' ), 'desc' => __('Decide if there is a small gap between the buttons or not', 'mashsb'), 'type' => 'checkbox', ), 'border_radius' => array( 'id' => 'border_radius', 'name' => __( 'Border Radius', 'mashsb' ), 'desc' => __( 'Specify the border radius of all buttons in pixel. A border radius of 20px results in circle buttons. Default value is zero.', 'mashsb' ), 'type' => 'select', 'options' => array( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, 'default' => 'default' ), 'std' => 'default' ), 'mash_style' => array( 'id' => 'mash_style', 'name' => __( 'Share Button Style', 'mashsb' ), 'desc' => __( 'Change visual appearance of the share buttons.', 'mashsb' ), 'type' => 'select', 'options' => array( 'shadow' => 'Shadowed', 'gradiant' => 'Gradient', 'default' => 'Flat' ), 'std' => 'default' ), 'small_buttons' => array( 'id' => 'small_buttons', 'name' => __( 'Small Share Buttons', 'mashsb' ), 'desc' => __( 'All buttons will be shown as pure small icons without any text on desktop and mobile devices all the time.
Note:Disable this if you want the buttons full width on desktop devices and small on mobile devices.', 'mashsb' ), 'type' => 'checkbox' ), 'text_align_center' => array( 'id' => 'text_align_center', 'name' => __( 'Text Align Center', 'mashsb' ), 'desc' => __( 'Buttons Text labels and social icons will be aligned in center of the buttons', 'mashsb' ), 'type' => 'checkbox' ), 'subscribe_behavior' => array( 'id' => 'subscribe_behavior', 'name' => __( 'Subscribe Button', 'mashsb' ), 'desc' => __( 'Specify if the subscribe button is opening a content box below the button or if the button is linked to the "subscribe url" below.', 'mashsb' ), 'type' => 'select', 'options' => array( 'content' => 'Open content box', 'link' => 'Open Subscribe Link' ), 'std' => 'content' ), 'subscribe_link' => array( 'id' => 'subscribe_link', 'name' => __( 'Subscribe URL', 'mashsb' ), 'desc' => __( 'Link the Subscribe button to this URL. This can be the url to your subscribe page, facebook fanpage, RSS feed etc. e.g. http://yoursite.com/subscribe', 'mashsb' ), 'type' => 'text', 'size' => 'regular', 'std' => '' ), 'additional_content' => array( 'id' => 'additional_content', 'name' => __( 'Additional Content', 'mashsb' ), 'desc' => __( '', 'mashsb' ), 'type' => 'add_content', 'options' => array( 'box1' => array( 'id' => 'content_above', 'name' => __( 'Content Above', 'mashsb' ), 'desc' => __( 'Content appearing above share buttons. Use HTML, formulars, like button, links or any other text. Shortcodes are supported, e.g.: [contact-form-7]', 'mashsb' ), 'type' => 'textarea', 'textarea_rows' => '3', 'size' => 15 ), 'box2' => array( 'id' => 'content_below', 'name' => __( 'Content Below', 'mashsb' ), 'desc' => __( 'Content appearing below share buttons. Use HTML, formulars, like button, links or any other text. Shortcodes are supported, e.g.: [contact-form-7]', 'mashsb' ), 'type' => 'textarea', 'textarea_rows' => '3', 'size' => 15 ), 'box3' => array( 'id' => 'subscribe_content', 'name' => __( 'Subscribe content', 'mashsb' ), 'desc' => __( 'Define the content of the opening toggle subscribe window here. Use formulars, like button, links or any other text. Shortcodes are supported, e.g.: [contact-form-7]', 'mashsb' ), 'type' => 'textarea', 'textarea_rows' => '3', 'size' => 15 ) ) ), 'additional_css' => array( 'id' => 'additional_css', 'name' => __( 'Custom Styles', 'mashsb' ), 'desc' => __( '', 'mashsb' ), 'type' => 'add_content', 'options' => array( 'box1' => array( 'id' => 'custom_css', 'name' => __( 'General CSS', 'mashsb' ), 'desc' => __( 'This css is loaded on all pages where the Mashshare buttons are enabled and it\'s loaded as an additonal inline css on your site', 'mashsb' ), 'type' => 'textarea', 'textarea_rows' => '3', 'size' => 15 ), 'box2' => array( 'id' => 'amp_css', 'name' => __( 'AMP CSS', 'mashsb' ), 'desc' => sprintf( __( 'This CSS is loaded only on AMP Project pages like yourwebsite.com/amp. Note: You need the WordPress AMP Plugin installed.', 'mashsb' ), 'https://wordpress.org/plugins/amp/' ), 'type' => 'textarea', 'textarea_rows' => '3', 'size' => 15 ), ) ), 'location_header' => array( 'id' => 'location_header', 'name' => '' . __( 'Position', 'mashsb' ) . '', 'desc' => __( '', 'mashsb' ), 'type' => 'header' ), 'mashsharer_position' => array( 'id' => 'mashsharer_position', 'name' => __( 'Position', 'mashsb' ), 'desc' => __( 'Position of Share Buttons. If this is set to manual use the shortcode function [mashshare] or use php code
<?php echo do_shortcode("[mashshare]"); ?> in template files.

You must activate the option "Load JS and CSS all over" if you experience issues with do_shortcode() and the buttons are not shown as expected. See all available shortcodes.', 'mashsb' ), 'type' => 'select', 'options' => array( 'before' => __( 'Top', 'mashsb' ), 'after' => __( 'Bottom', 'mashsb' ), 'both' => __( 'Top and Bottom', 'mashsb' ), 'manual' => __( 'Manual', 'mashsb' ) ) ), 'post_types' => array( 'id' => 'post_types', 'name' => __( 'Post Types', 'mashsb' ), 'desc' => __( 'Select on which post_types the share buttons appear. These values will be ignored when "manual" position is selected.', 'mashsb' ), 'type' => 'posttypes' ), 'excluded_from' => array( 'id' => 'excluded_from', 'name' => __( 'Exclude from post id', 'mashsb' ), 'desc' => __( 'Exclude share buttons from a list of post ids. Put in the post id separated by a comma, e.g. 23, 63, 114 ', 'mashsb' ), 'type' => 'text', 'size' => 'medium' ), 'singular' => array( 'id' => 'singular', 'name' => __( 'Categories', 'mashsb' ), 'desc' => __( 'Enable this checkbox to enable Mashshare on categories with multiple blogposts.
Note: Post_types: "Post" must be enabled.', 'mashsb' ), 'type' => 'checkbox', 'std' => '0' ), 'frontpage' => array( 'id' => 'frontpage', 'name' => __( 'Frontpage', 'mashsb' ), 'desc' => __( 'Enable share buttons on frontpage', 'mashsb' ), 'type' => 'checkbox' ), array( 'id' => 'shorturl_header', 'name' => '' . __( 'Short URLs', 'mashsb' ) . '', 'desc' => '', 'type' => 'header', 'size' => 'regular' ), array( 'id' => 'bitly_access_token', 'name' => __( 'Bitly access token', 'mashsb' ), 'desc' => sprintf(__( 'If you like to use bitly.com shortener get a free bitly access token here. This turn urls into a format: http://bit.ly/cXnjsh. ', 'mashsb' ), 'https://bitly.com/a/oauth_apps'), 'type' => 'text', 'size' => 'large' ), array( 'id' => 'mashsu_methods', 'name' => __( 'Shorturl method', 'mashsb' ), 'desc' => sprintf(__('Bitly generated shortlinks will be converted to the url format: http://bit.ly/1PPg9D9

Goo.gl generated urls look like:
http://goo.gl/vSJwUV

Using WP Shortlinks converts twitter links into:
%s ?p=101', 'mashsb'), get_site_url() ), 'type' => 'select', 'options' => array( 'wpshortlinks' => 'WP Short links', 'bitly' => 'Bitly', 'disabled' => 'Short URLs Disabled', ) ), array( 'id' => 'shorturl_explanation', 'name' => __( 'Important: Read this!', 'mashsb' ), 'desc' => __('The post short url is NOT generated immediatly after first page load! Background processing can take up to 1 hour for new posts and 4 - 12 hours for old posts.','mashsb'), 'type' => 'renderhr', 'size' => 'large' ), 'debug_header' => array( 'id' => 'debug_header', 'name' => '' . __( 'Debug', 'mashsb' ) . '', 'desc' => __( '', 'mashsb' ), 'type' => 'header' ), array( 'id' => 'disable_cache', 'name' => __( 'Disable Cache', 'mashsb' ), 'desc' => __( 'Note: Use this only for testing to see if shares are counted! Your page loading performance will drop. Works only when sharecount is enabled.
' . mashsb_cache_status(), 'mashsb' ), 'type' => 'checkbox' ), 'delete_cache_objects' => array( 'id' => 'delete_cache_objects', 'name' => __( 'Attention: Purge DB Cache', 'mashsb' ), 'desc' => __( 'Caution Use this as last resort. This will delete all your share counts stored in mashshare post_meta objects and it takes hours to get them back. Usually this option is not needed!
' . mashsb_delete_cache_objects(), 'mashsb' ), 'type' => 'checkbox' ), 'debug_mode' => array( 'id' => 'debug_mode', 'name' => __( 'Debug mode', 'mashsb' ), 'desc' => __( 'Note: Check this box before you get in contact with our support team. This allows us to check publically hidden debug messages on your website. Do not forget to disable it thereafter! Enable this also to write daily sorted log files of requested share counts to folder /wp-content/plugins/mashsharer/logs. Please send us this files when you notice a wrong share count.' . mashsb_log_permissions(), 'mashsb' ), 'type' => 'checkbox' ), 'fb_debug' => array( 'id' => 'fb_debug', 'name' => __( '', 'mashsb' ), 'desc' => '', 'type' => 'ratelimit' ), ) ), 'licenses' => apply_filters( 'mashsb_settings_licenses', array( 'licenses_header' => array( 'id' => 'licenses_header', 'name' => __( 'Activate your Add-Ons', 'mashsb' ), 'desc' => mashsb_check_active_addons() ? __('Activate your license key to get important security and feature updates for your Add-On!','mashsb') : sprintf(__('No Add-Ons are active or installed! See all Add-Ons','mashsb'), 'https://www.mashshare.net/add-ons/?utm_source=insideplugin&utm_medium=userwebsite&utm_content=see_all_add_ons&utm_campaign=freeplugin'), 'type' => 'header' ),) ), 'extensions' => apply_filters( 'mashsb_settings_extension', array()), 'addons' => apply_filters( 'mashsb_settings_addons', array( 'addons' => array( 'id' => 'addons', 'name' => __( '', 'mashsb' ), 'desc' => __( '', 'mashsb' ), 'type' => 'addons' ), ) ) ); return $mashsb_settings; } /** * Settings Sanitization * * Adds a settings error (for the updated message) * At some point this will validate input * * @since 1.0.0 * * @param array $input The value input in the field * * @return string $input Sanitized value */ function mashsb_settings_sanitize( $input = array() ) { global $mashsb_options; if( empty( $_POST['_wp_http_referer'] ) ) { return $input; } parse_str( $_POST['_wp_http_referer'], $referrer ); $settings = mashsb_get_registered_settings(); $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; $input = $input ? $input : array(); $input = apply_filters( 'mashsb_settings_' . $tab . '_sanitize', $input ); // Loop through each setting being saved and pass it through a sanitization filter foreach ( $input as $key => $value ) { // Get the setting type (checkbox, select, etc) $type = isset( $settings[$tab][$key]['type'] ) ? $settings[$tab][$key]['type'] : false; // General filter $input[$key] = apply_filters( 'mashsb_settings_sanitize', $value, $key ); if( $type ) { // Field type specific filter $input[$key] = apply_filters( 'mashsb_settings_sanitize_' . $type, $value, $key ); } } // Loop through the whitelist and unset any that are empty for the tab being saved if( !empty( $settings[$tab] ) ) { foreach ( $settings[$tab] as $key => $value ) { // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work if( is_numeric( $key ) ) { $key = $value['id']; } if( empty( $input[$key] ) ) { unset( $mashsb_options[$key] ); } } } // Merge our new settings with the existing $output = array_merge( $mashsb_options, $input ); add_settings_error( 'mashsb-notices', '', __( 'Settings updated.', 'mashsb' ), 'updated' ); return $output; } /** * Sanitize text fields * * @since 1.8 * @param array $input The field value * @return string $input Sanitized value */ function mashsb_sanitize_text_field( $input ) { $allowedTags = '