Example #1
0
function synved_option_callback_create($callback_code, $callback_parameters = null)
{
    if ($callback_parameters === null) {
        $callback_parameters = array('value' => array(), 'item' => array('default' => null), 'name' => array('default' => null), 'id' => array('default' => null));
    } else {
        if (!is_array($callback_parameters)) {
            $parameters = explode(',', $callback_parameters);
            $callback_parameters = array();
            foreach ($parameters as $param) {
                $param = trim($param);
                $param_info = preg_split('/\\s+/', $param, -1, PREG_SPLIT_NO_EMPTY);
                if (count($param_info) > 1) {
                    if ($param_info[1] == '=') {
                        array_unshift($param_info, null);
                    }
                    $param_type = $param_info[0];
                    $param_name = ltrim($param_info[1], '$');
                    $param_manifest = array('type' => $param_type);
                    if (count($param_info) > 2) {
                        if ($param_info[2] == '=' && isset($param_info[3])) {
                            $param_default = trim($param_info[3]);
                            if ($param_default == 'null') {
                                $param_default = null;
                            } else {
                                if (in_array($param_default[0], array('\'', '"'))) {
                                    $param_default = trim($param_default, '"\'');
                                } else {
                                    if (strpos($param_default, 'array()') === 0) {
                                        $param_default = array();
                                    } else {
                                        if (strpos($param_default, 'array(') === 0) {
                                            // No array support
                                            $param_default = null;
                                        } else {
                                            if (is_string($param_default)) {
                                                // int or double (float)
                                                if ((string) (int) $param_default == $param_default) {
                                                    $param_default = (int) $param_default;
                                                } else {
                                                    $param_default = (double) $param_default;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            $param_manifest['default'] = $param_default;
                        }
                    }
                    $callback_parameters[$param_name] = $param_manifest;
                } else {
                    $param_name = ltrim($param_info[0], '$');
                    $callback_parameters[$param_name] = array();
                }
            }
        }
    }
    $callback_code = trim($callback_code);
    $callback = null;
    if ($callback_code != null) {
        if (substr($callback_code, -1) != ';') {
            $callback_code .= ';';
        }
        if (strpos($callback_code, 'return') === false) {
            $result = preg_split('/(?:([\'"])([^\\1]*\\1))|(;)/i', $callback_code, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
            $count = count($result);
            $partial = null;
            $string = null;
            $lines = array();
            for ($i = 0; $i < $count; $i++) {
                $split = $result[$i];
                if ($string != null) {
                    $partial .= $string . $split;
                    $string = null;
                } else {
                    if ($split == ';') {
                        $split = $partial;
                        $partial = null;
                    } else {
                        if ($split == '\'') {
                            $string = $split;
                        } else {
                            $partial .= $split;
                        }
                    }
                }
                if ($split != null && $partial == null) {
                    $lines[] = $split;
                }
            }
            $count = count($lines);
            $lines[$count - 1] = 'return ' . $lines[$count - 1];
            $callback_code = implode(';', $lines) . ';';
        }
        $function_params = null;
        foreach ($callback_parameters as $param_name => $callback_param) {
            $param_type = isset($callback_param['type']) ? $callback_param['type'] : null;
            $param_default = isset($callback_param['default']) ? $callback_param['default'] : null;
            if ($function_params != null) {
                $function_params .= ', ';
            }
            if ($param_type != null) {
                $function_params .= $param_type;
            }
            $function_params .= '$' . $param_name;
            if ($param_default != null) {
                $function_params .= ' = ' . $param_default;
            }
        }
        $callback = create_function($function_params, $callback_code);
        return synved_option_callback($callback, null, $callback_parameters);
    }
    return null;
}
function synved_option_item_callback(array $item, $callback_id, $callback_parameters = null)
{
    $callback = isset($item[$callback_id]) ? $item[$callback_id] : null;
    if ($callback != null) {
        $callback = trim($callback);
        if (is_string($callback) && !function_exists($callback)) {
            $callback = synved_option_callback_create($callback_code, $callback_parameters);
        }
        if (!$callback instanceof SynvedOptionCallback) {
            if (is_callable($callback)) {
                $callback = synved_option_callback($callback);
            } else {
                $callback = null;
            }
        }
    }
    return $callback;
}
                }
            }
        }
        $providers_settings = array_merge($providers_settings, array($provider_name . '_display' => array('default' => $display_default, 'style' => 'group', 'set' => $display_set, 'label' => __($provider_label . ' Service', 'social-media-feather'), 'tip' => __('Decides for what types of services ' . $provider_label . ' will be used by default', 'social-media-feather'))));
        if (isset($share_providers[$provider_name])) {
            $share_item = $share_providers[$provider_name];
            $providers_settings = array_merge($providers_settings, array($provider_name . '_share_link' => array('label' => __($provider_label . ' Share Link', 'social-media-feather'), 'tip' => __('The link used by default for sharing content on ' . $provider_label . '. <b>Note: this generally doesn\'t need to be changed, only change it if you know what you\'re doing.</b>', 'social-media-feather'), 'hint' => $share_item['link']), $provider_name . '_share_title' => array('label' => __($provider_label . ' Share Title', 'social-media-feather'), 'tip' => __('The title used by default for the ' . $provider_label . ' share button (a standard one will be used if left empty)', 'social-media-feather'), 'hint' => $share_item['title'])));
        }
        if (isset($follow_providers[$provider_name])) {
            $follow_item = $follow_providers[$provider_name];
            $providers_settings = array_merge($providers_settings, array($provider_name . '_follow_link' => array('label' => __($provider_label . ' Follow Link', 'social-media-feather'), 'tip' => __('The link used by default for following you on ' . $provider_label . '. Change this to point to your own social profile page on ' . $provider_label . '.', 'social-media-feather'), 'hint' => $follow_item['link']), $provider_name . '_follow_title' => array('label' => __($provider_label . ' Follow Title', 'social-media-feather'), 'tip' => __('The title used by default for the ' . $provider_label . ' follow button (a standard one will be used if left empty)', 'social-media-feather'), 'hint' => $follow_item['title'])));
        }
    }
    return $providers_settings;
}
$synved_social_options = array('settings' => array('label' => 'Social Media', 'title' => 'Social Media Feather', 'tip' => synved_option_callback('synved_social_page_settings_tip'), 'link-target' => plugin_basename(synved_plugout_module_path_get('synved-social', 'provider')), 'render-fragment' => 'synved_social_page_render_fragment', 'sections' => array('section_general' => array('label' => __('General Settings', 'social-media-feather'), 'tip' => __('Settings affecting the general behaviour of the plugin', 'social-media-feather'), 'settings' => array('use_shortlinks' => array('default' => false, 'label' => __('Use Shortlinks', 'social-media-feather'), 'tip' => __('Allows for shortened URLs to be used when sharing content if a shortening plugin is installed', 'social-media-feather')), 'share_full_url' => array('default' => false, 'label' => __('Share Full URL', 'social-media-feather'), 'tip' => __('Determines whether to always share the full URL or just the post permalink. You can override this for individual posts by setting the "synved_social_share_full_url" custom field to either "yes" or "no", case sensitive', 'social-media-feather')), 'layout_rtl' => array('default' => false, 'label' => __('Right To Left Layout', 'social-media-feather'), 'tip' => __('Check this option if you have a right-to-left site layout and icons show spacing issues', 'social-media-feather')), 'shortcode_widgets' => array('default' => true, 'label' => __('Shortcodes In Widgets', 'social-media-feather'), 'tip' => __('Allow shortcodes in Text widgets', 'social-media-feather')), 'show_credit' => array('default' => false, 'label' => __('Show Credit', 'social-media-feather'), 'tip' => __('Display a small icon with a link to the Social Media Feather page', 'social-media-feather')), 'share_message_default' => array('default' => __('Hey check this out', 'social-media-feather'), 'label' => __('Default Message', 'social-media-feather'), 'tip' => __('Specify the default message to use when sharing content, this is what gets replaced into the %%message%% variable', 'social-media-feather')))), 'section_automatic_display' => array('label' => __('Automatic Display', 'social-media-feather'), 'tip' => __('Settings affecting automating appending of social buttons to post contents', 'social-media-feather'), 'settings' => array('automatic_share' => array('default' => false, 'label' => __('Display Sharing Buttons', 'social-media-feather'), 'tip' => __('Tries to automatically append sharing buttons to your posts (disable for specific posts by setting custom field synved_social_exclude or synved_social_exclude_share to "yes", case sensitive)', 'social-media-feather')), 'automatic_share_position' => array('default' => 'after_post', 'set' => 'after_post=After Post,before_post=Before Post,after_before_post=After and Before Post', 'label' => __('Share Buttons Position', 'social-media-feather'), 'tip' => __('Select where the sharing buttons should be placed. Note: placing buttons Before Post might not work in all themes.', 'social-media-feather')), 'automatic_share_single' => array('default' => false, 'label' => __('Sharing Single Posts', 'social-media-feather'), 'tip' => __('Sharing buttons are only displayed on single posts/pages and not on archive pages like blog/category/tag/author pages', 'social-media-feather')), 'automatic_share_post_types' => array('type' => 'custom', 'default' => 'post', 'set' => synved_option_callback('synved_social_automatic_append_post_types_set', array('post', 'page')), 'label' => __('Share Post Types', 'social-media-feather'), 'tip' => __('Post types for which automatic appending for share buttons should be attempted (CTRL + click to select multiple ones)', 'social-media-feather'), 'render' => 'synved_social_automatic_append_post_types_render'), 'automatic_share_prefix' => array('default' => '', 'label' => __('Share Prefix Markup', 'social-media-feather'), 'tip' => __('When automatically appending, place this markup before the share buttons markup', 'social-media-feather')), 'automatic_share_postfix' => array('default' => '', 'label' => __('Share Postfix Markup', 'social-media-feather'), 'tip' => __('When automatically appending, place this markup after all of the share buttons markup', 'social-media-feather')), 'automatic_follow' => array('default' => false, 'label' => __('Display Follow Buttons', 'social-media-feather'), 'tip' => __('Tries to automatically append follow buttons to your posts (disable for specific posts by setting custom field synved_social_exclude or synved_social_exclude_follow to "yes", case sensitive)', 'social-media-feather')), 'automatic_follow_position' => array('default' => 'after_post', 'set' => 'after_post=After Post,before_post=Before Post,after_before_post=After and Before Post', 'label' => __('Follow Buttons Position', 'social-media-feather'), 'tip' => __('Select where the follow buttons should be placed. Note: placing buttons Before Post might not work in all themes.', 'social-media-feather')), 'automatic_follow_single' => array('default' => false, 'label' => __('Follow Single Posts', 'social-media-feather'), 'tip' => __('Follow buttons are only displayed on single posts/pages and not on archive pages like blog/category/tag/author pages', 'social-media-feather')), 'automatic_follow_post_types' => array('type' => 'custom', 'default' => 'post', 'set' => synved_option_callback('synved_social_automatic_append_post_types_set', array('post', 'page')), 'label' => __('Follow Post Types', 'social-media-feather'), 'tip' => __('Post types for which automatic appending for follow buttons should be attempted (CTRL + click to select multiple ones)', 'social-media-feather'), 'render' => 'synved_social_automatic_append_post_types_render'), 'automatic_follow_before_share' => array('default' => false, 'label' => __('Follow Before Share', 'social-media-feather'), 'tip' => __('When automatically appending, place follow buttons before share buttons. Only valid when share and follow buttons positions are the same.', 'social-media-feather')), 'automatic_follow_prefix' => array('default' => '', 'label' => __('Follow Prefix Markup', 'social-media-feather'), 'tip' => __('When automatically appending, place this markup before the follow buttons markup', 'social-media-feather')), 'automatic_follow_postfix' => array('default' => '', 'label' => __('Follow Postfix Markup', 'social-media-feather'), 'tip' => __('When automatically appending, place this markup after all of the follow buttons markup', 'social-media-feather')), 'automatic_append_prefix' => array('default' => '', 'label' => __('Prefix Markup', 'social-media-feather'), 'tip' => __('When automatically appending, place this markup before the buttons markup', 'social-media-feather')), 'automatic_append_separator' => array('default' => '<br/>', 'label' => __('Separator Markup', 'social-media-feather'), 'tip' => __('When automatically appending both, use this markup as separator between the set of share buttons and the set of follow buttons. Only valid when share and follow buttons positions are the same.', 'social-media-feather')), 'automatic_append_postfix' => array('default' => '', 'label' => __('Postfix Markup', 'social-media-feather'), 'tip' => __('When automatically appending, place this markup after all of the buttons markup', 'social-media-feather')))), 'section_customize_look' => array('label' => __('Customize Look', 'social-media-feather'), 'tip' => synved_option_callback('synved_social_section_customize_look_tip', __('Customize the look & feel of Social Media Feather', 'social-media-feather')), 'settings' => array('icon_skin' => array('default' => 'regular', 'set' => synved_option_callback('synved_social_cb_icon_skin_set', 'regular=Regular'), 'label' => __('Icon Skin', 'social-media-feather'), 'tip' => synved_option_callback('synved_social_setting_icon_skin_tip', __('Select the default skin to use for the icons', 'social-media-feather')), 'render' => 'synved_social_icon_skin_render'), 'addon_extra_icons' => array('type' => 'addon', 'target' => SYNVED_SOCIAL_ADDON_PATH, 'folder' => 'extra-icons', 'module' => 'synved-social', 'style' => 'addon-important', 'label' => __('Extra Icon Skins', 'social-media-feather'), 'tip' => synved_option_callback('synved_social_option_addon_extra_icons_tip', __('Click the button to install the "Extra Social Icons" addon, get it <a target="_blank" href="http://synved.com/product/feather-extra-social-icons/">here</a>.', 'social-media-feather'))), 'addon_grey_fade' => array('type' => 'addon', 'target' => SYNVED_SOCIAL_ADDON_PATH, 'folder' => 'grey-fade', 'module' => 'synved-social', 'style' => 'addon-important', 'label' => __('Grey Fade Effect', 'social-media-feather'), 'tip' => synved_option_callback('synved_social_option_addon_grey_fade_tip', __('Click the button to install the "Grey Fade" addon, get it <a target="_blank" href="http://synved.com/product/feather-grey-fade/">here</a>.', 'social-media-feather'))), 'addon_light_prompt' => array('type' => 'addon', 'target' => SYNVED_SOCIAL_ADDON_PATH, 'folder' => 'light-prompt', 'module' => 'synved-social', 'style' => 'addon-important', 'label' => __('Light Prompt Overlay', 'social-media-feather'), 'tip' => synved_option_callback('synved_social_option_addon_light_prompt_tip', __('Click the button to install the "Light Prompt" addon, get it <a target="_blank" href="http://synved.com/product/feather-light-prompt/">here</a>.', 'social-media-feather'))), 'icon_size' => array('default' => 48, 'set' => '16=16x16,24=24x24,32=32x32,48=48x48,64=64x64,96=96x96', 'label' => __('Icon Size', 'social-media-feather'), 'tip' => __('Select the size in pixels for the icons. Note: for high resolution displays like Retina the maximum size is 64x64.', 'social-media-feather')), 'icon_resolution' => array('default' => 'single', 'set' => 'single=Single,double=Double', 'label' => __('Icon Resolution', 'social-media-feather'), 'tip' => __('Select what icon resolutions will be used. Single might make the icons slightly blurry on low resolution displays. Double will always look the best but will consume more bandwidth.', 'social-media-feather')), 'icon_spacing' => array('default' => 5, 'label' => __('Icon Spacing', 'social-media-feather'), 'tip' => __('Select the spacing in pixels between the icons', 'social-media-feather')), 'buttons_container' => array('default' => 'none', 'set' => 'none=None,share=Sharing Buttons,follow=Following Buttons,both=Both', 'label' => __('Buttons in Container', 'social-media-feather'), 'tip' => __('Determines whether or not to wrap the buttons in a container, which will affect how the buttons are rendered, based on the "Buttons Container Type" setting.', 'social-media-feather')), 'buttons_container_type' => array('default' => 'basic', 'set' => 'basic=Basic,block=Block', 'label' => __('Buttons Container Type', 'social-media-feather'), 'tip' => __('"Basic" should not affect rendering, while "Block" should display the buttons in their own row. <b>Note</b>: selecting "Block" might not look the way you want if you\'re using Prefix or Postfix markup.', 'social-media-feather')), 'buttons_alignment_share' => array('default' => 'none', 'set' => 'none=Theme Default,left=Align Left,right=Align Right,center=Align Center', 'label' => __('Share Buttons Alignment', 'social-media-feather'), 'tip' => __('Will attempt at aligning the share buttons accordingly. <strong>Note:</strong> this will enforce "Buttons Container Type" of "Block" and might not work reliably on all themes', 'social-media-feather')), 'buttons_alignment_follow' => array('default' => 'none', 'set' => 'none=Theme Default,left=Align Left,right=Align Right,center=Align Center', 'label' => __('Follow Buttons Alignment', 'social-media-feather'), 'tip' => __('Will attempt at aligning the follow buttons accordingly. <strong>Note:</strong> this will enforce "Buttons Container Type" of "Block" and might not work reliably on all themes', 'social-media-feather')), 'custom_style' => array('type' => 'style', 'label' => __('Extra Styles', 'social-media-feather'), 'tip' => __('Any CSS styling code you type in here will be loaded after all of the Social Media Feather styles.', 'social-media-feather')))), 'section_service_providers' => array('label' => __('Service Providers', 'social-media-feather'), 'tip' => __('Customize social sharing and following providers', 'social-media-feather'), 'settings' => synved_social_provider_settings()))));
synved_option_register('synved_social', $synved_social_options);
synved_option_include_module_addon_list('synved-social');
function synved_social_provider_option_value_sanitize($value, $name, $id, $item)
{
    $default = synved_option_item_default($item);
    if ($value == $default) {
    }
}
function synved_social_page_settings_tip($tip, $item)
{
    if (!function_exists('synved_shortcode_version')) {
        $tip .= ' <div style="background:#f2f2f2;font-size:110%;color:#444;margin-right:270px;padding:10px 15px;"><b>' . __('Note', 'social-media-feather') . '</b>: ' . sprintf(__('The Social Media Feather plugin is fully compatible with our free <a target="_blank" href="%1$s">WordPress Shortcodes</a> plugin! WordPress Shortcodes will simplify adding Social Media shortcodes to your posts and pages! You can install it using your <a href="%2$s">plugin installer</a>.', 'social-media-feather'), 'http://synved.com/wordpress-shortcodes/', add_query_arg(array('tab' => 'search', 's' => 'synved shortcodes'), admin_url('plugin-install.php'))) . '</div>';
    }
    if (function_exists('synved_connect_support_social_follow_render')) {
        $tip .= synved_connect_support_social_follow_render();
<?php

$synved_shortcode_options = array('synved_shortcode' => array('label' => 'Shortcodes', 'title' => 'WordPress Shortcodes', 'tip' => synved_option_callback('synved_shortcode_page_settings_tip'), 'link-target' => plugin_basename(synved_plugout_module_path_get('synved-shortcode', 'provider')), 'render-fragment' => 'synved_shortcode_page_render_fragment', 'sections' => array('customize_look' => array('label' => __('Customize Look', 'synved-shortcode'), 'tip' => synved_option_callback('synved_shortcode_section_customize_look_tip', __('Customize the look & feel of WordPress Shortcodes', 'synved-shortcode')), 'settings' => array('shortcode_widgets' => array('default' => true, 'label' => __('Shortcodes In Widgets', 'synved-shortcode'), 'tip' => __('Allow shortcodes in Text widgets', 'synved-shortcode')), 'shortcode_feed' => array('default' => true, 'label' => __('Shortcodes In Feeds', 'synved-shortcode'), 'tip' => __('Allow shortcodes in Feeds (RSS, Atom, etc.)', 'synved-shortcode')), 'custom_skin' => array('default' => 'basic', 'set' => synved_option_callback('synved_shortcode_custom_skin_set', 'basic=Basic'), 'label' => __('Select Skin', 'synved-shortcode'), 'tip' => __('Select the skin to use for WordPress Shortcodes', 'synved-shortcode')), 'skin_slickpanel' => array('type' => 'addon', 'target' => SYNVED_SHORTCODE_ADDON_PATH, 'folder' => 'skin-slickpanel', 'module' => 'synved-shortcode', 'style' => 'addon-important', 'label' => __('SlickPanel Skin', 'synved-shortcode'), 'tip' => synved_option_callback('synved_shortcode_option_skin_slickpanel_tip', __('Click the button to install the SlickPanel skin, get it <a target="_blank" href="http://synved.com/product/wordpress-shortcodes-slickpanel-skin/">here</a>.', 'synved-shortcode'))), 'addon_extra_presets' => array('type' => 'addon', 'target' => SYNVED_SHORTCODE_ADDON_PATH, 'folder' => 'extra-presets', 'module' => 'synved-shortcode', 'style' => 'addon-important', 'label' => __('Extra Presets', 'synved-shortcode'), 'tip' => synved_option_callback('synved_shortcode_option_addon_extra_presets_tip', __('Click the button to install the "Extra Presets" addon, get it <a target="_blank" href="http://synved.com/product/wordpress-shortcodes-extra-presets/">here</a>.', 'synved-shortcode'))), 'custom_style' => array('type' => 'style', 'label' => __('Extra Styles', 'synved-shortcode'), 'tip' => __('Any CSS styling code you type in here will be loaded after all of the WordPress Shortcodes styles.', 'synved-shortcode')))))));
synved_option_register('synved_shortcode', $synved_shortcode_options);
synved_option_include_module_addon_list('synved-shortcode');
function synved_shortcode_page_settings_tip($tip, $item)
{
    if (!function_exists('synved_social_version')) {
        $tip .= ' <div style="background:#f2f2f2;font-size:110%;color:#444;margin-right:270px;padding:10px 15px;"><b>' . __('Note', 'synved-shortcode') . '</b>: ' . sprintf(__('The WordPress Shortcodes plugin is fully compatible with our free <a target="_blank" href="%1$s">Social Media Feather</a> plugin! Social Media Feather makes social sharing and following a breeze! You can install it using your <a href="%2$s">plugin installer</a>.', 'synved-shortcode'), 'http://synved.com/wordpress-social-media-feather/', add_query_arg(array('tab' => 'search', 's' => 'social media feather'), admin_url('plugin-install.php'))) . '</div>';
    }
    if (function_exists('synved_connect_support_social_follow_render')) {
        $tip .= synved_connect_support_social_follow_render();
    }
    return $tip;
}
function synved_shortcode_page_render_fragment($fragment, $out, $params)
{
    if ($fragment == 'page-submit-tail') {
        $out .= '<div style="clear:both; margin-top: -12px;"><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/synved-shortcodes?rate=5#postform" style="font-size:120%"><b>We need your help!</b> If you like the plugin, you can help us by leaving a 5-stars review! It only takes a minute and it\'s free!</a></a></div>';
    }
    return $out;
}
function synved_shortcode_section_customize_look_tip($tip, $item)
{
    if (!synved_option_addon_installed('synved_shortcode', 'skin_slickpanel')) {
        $tip .= '<p style="font-size:120%;"><b>Want a slicker, more professional look for your shortcodes? Get the <a target="_blank" href="http://synved.com/product/wordpress-shortcodes-slickpanel-skin/">SlickPanel skin</a></b>!</p> <a target="_blank" href="http://synved.com/product/wordpress-shortcodes-slickpanel-skin/"><img src="' . synved_shortcode_path_uri() . '/image/skin-slickpanel.png" /></a>';
    }
    return $tip;
}
function synved_shortcode_custom_skin_set($set, $item)
{