function ssba_admin_panel($arrSettings) { // set var $htmlShareButtonsForm = ''; // if user is accepting terms if (isset($_GET['accept-terms']) && $_GET['accept-terms'] == 'Y') { // save acceptance ssba_update_options(array('accepted_sharethis_terms' => 'Y')); // hide the notice for now, it will disappear upon reload $htmlShareButtonsForm .= '<style>#sharethis_terms_notice { display: none }.ssbp-facebook_save { background-color: #365397 !important; }</style>'; // show notice add_action('admin_notices', 'accepted_sharethis_terms_notice'); } // include the forms helper include_once 'ssbp_forms.php'; // prepare array of buttons $arrButtons = json_decode(get_option('ssba_buttons'), true); // get the font family needed $htmlShareButtonsForm .= '<style>' . ssba_get_font_family() . '</style>'; // if left to right if (is_rtl()) { // move save button $htmlShareButtonsForm .= '<style>.ssba-btn-save{left: 0!important; right: auto !important; border-radius: 0 5px 5px 0;} </style>'; } // add header $htmlShareButtonsForm .= ssba_admin_header(); // initiate forms helper $ssbpForm = new ssbpForms(); // opening form tag $htmlShareButtonsForm .= $ssbpForm->open(false); // heading $htmlShareButtonsForm .= '<h2>Share Buttons Settings</h2>'; // if terms have just been accepted if (isset($_GET['accept-terms']) && $_GET['accept-terms'] == 'Y') { $htmlShareButtonsForm .= '<div class="alert alert-success text-center"> <p>Thanks for accepting the terms, you can now take advantage of the great new features!</p> </div>'; } elseif ($arrSettings['accepted_sharethis_terms'] != 'Y') { $htmlShareButtonsForm .= '<div class="alert alert-warning text-center"> <p>The Facebook save button requires acceptance of the terms before it can be used. <a href="options-general.php?page=simple-share-buttons-adder&accept-terms=Y"><span class="button button-secondary">I accept</span></a></p> </div>'; } // tabs $htmlShareButtonsForm .= '<ul class="nav nav-tabs"> <li class="active"><a href="#core" data-toggle="tab">Core</a></li> <li><a href="#styling" data-toggle="tab">Styling</a></li> <li><a href="#counters" data-toggle="tab">Counters</a></li> <li><a href="#advanced" data-toggle="tab">Advanced</a></li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"> CSS <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="#css_additional" data-toggle="tab">Additional</a></li> <li><a href="#css_custom" data-toggle="tab">Custom</a></li> </ul> </li> </ul>'; // tab content div $htmlShareButtonsForm .= '<div id="ssbaTabContent" class="tab-content">'; //====================================================================== // CORE //====================================================================== $htmlShareButtonsForm .= '<div class="tab-pane fade active in" id="core">'; // basic info $htmlShareButtonsForm .= '<blockquote><p>The <b>simple</b> options you can see below are all you need to complete to get your <b>share buttons</b> to appear on your website. Once you\'re done here, you can further customise the share buttons via the Styling tab.</p></blockquote>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-12">'; // locations array $locs = array('Homepage' => array('value' => 'ssba_homepage', 'checked' => $arrSettings['ssba_homepage'] == 'Y' ? true : false), 'Pages' => array('value' => 'ssba_pages', 'checked' => $arrSettings['ssba_pages'] == 'Y' ? true : false), 'Posts' => array('value' => 'ssba_posts', 'checked' => $arrSettings['ssba_posts'] == 'Y' ? true : false), 'Excerpts' => array('value' => 'ssba_excerpts', 'checked' => $arrSettings['ssba_excerpts'] == 'Y' ? true : false), 'Categories/Archives' => array('value' => 'ssba_cats_archs', 'checked' => $arrSettings['ssba_cats_archs'] == 'Y' ? true : false)); // locations $opts = array('form_group' => false, 'label' => 'Locations', 'tooltip' => 'Enable the locations you wish for share buttons to appear', 'value' => 'Y', 'checkboxes' => $locs); $htmlShareButtonsForm .= $ssbpForm->ssbp_checkboxes($opts); // placement $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_before_or_after', 'label' => 'Placement', 'tooltip' => 'Place share buttons before or after your content', 'selected' => $arrSettings['ssba_before_or_after'], 'options' => array('After' => 'after', 'Before' => 'before', 'Both' => 'both')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // share text $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'Keeping sharing simple...', 'name' => 'ssba_share_text', 'label' => 'Share Text', 'tooltip' => 'Add some custom text by your share buttons', 'value' => $arrSettings['ssba_share_text']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // networks $htmlShareButtonsForm .= '<label for="ssba_choices" class="control-label" data-toggle="tooltip" data-placement="right" data-original-title="Drag, drop and reorder those buttons that you wish to include">Networks</label> <div class="">'; $htmlShareButtonsForm .= '<div class="ssbp-wrap ssbp--centred ssbp--theme-4"> <div class="ssbp-container"> <ul id="ssbasort1" class="ssbp-list ssbaSortable">'; $htmlShareButtonsForm .= getAvailableSSBA($arrSettings['ssba_selected_buttons'], $arrSettings); $htmlShareButtonsForm .= '</ul> </div> </div>'; $htmlShareButtonsForm .= '<div class="well">'; $htmlShareButtonsForm .= '<div class="ssba-well-instruction"><i class="fa fa-download"></i> Drop icons below</div>'; $htmlShareButtonsForm .= '<div class="ssbp-wrap ssbp--centred ssbp--theme-4"> <div class="ssbp-container"> <ul id="ssbasort2" class="ssba-include-list ssbp-list ssbaSortable">'; $htmlShareButtonsForm .= getSelectedSSBA($arrSettings['ssba_selected_buttons'], $arrSettings); $htmlShareButtonsForm .= '</ul> </div>'; $htmlShareButtonsForm .= '</div>'; $htmlShareButtonsForm .= '</div>'; $htmlShareButtonsForm .= '<input type="hidden" name="ssba_selected_buttons" id="ssba_selected_buttons" value="' . $arrSettings['ssba_selected_buttons'] . '"/>'; // plus plug $htmlShareButtonsForm .= '<div class="well text-center">'; $htmlShareButtonsForm .= '<h2>Simple Share Buttons Plus</h2>'; $htmlShareButtonsForm .= '<h5 class="margin-bottom">Get <strong>Xing</strong> and <strong>WhatsApp</strong> buttons...</h5>'; $htmlShareButtonsForm .= '<div class="ssbp-wrap ssbp--centred ssbp--theme-4"> <div class="ssbp-container"> <ul class="ssbp-list"> <li class="ssbp-option-item ui-sortable-handle" id="buffer"><a href="javascript:;" class="ssbp-btn ssbp-whatsapp"></a></li> <li class="ssbp-option-item ui-sortable-handle" id="diggit"><a href="javascript:;" class="ssbp-btn ssbp-xing"></a></li> </ul> </div> </div>'; $htmlShareButtonsForm .= '<a href="https://simplesharebuttons.com/plus/?utm_source=adder&utm_medium=plugin_ad&utm_campaign=product&utm_content=feature" target="_blank"><span class="btn btn-primary">Simple Share Buttons Plus</span></a>'; $htmlShareButtonsForm .= '<div class="ssba-spacer"></div>'; $htmlShareButtonsForm .= '<p>Extra buttons are just the tip of the iceberg... <strong>Simple Share Buttons Plus</strong> comes with a great deal of extra features, from <strong>GeoIP click tracking</strong> to <strong>mobile-responsive</strong> share bars. <a href="https://simplesharebuttons.com/plus/?utm_source=adder&utm_medium=plugin_ad&utm_campaign=product&utm_content=feature" target="_blank"><strong>Find out more here</strong></a></p>'; $htmlShareButtonsForm .= '<div class="ssba-spacer"></div>'; $htmlShareButtonsForm .= '</div>'; $htmlShareButtonsForm .= '</div>'; // close col $htmlShareButtonsForm .= '</div>'; // close share buttons tab $htmlShareButtonsForm .= '</div>'; //====================================================================== // STYLING //====================================================================== $htmlShareButtonsForm .= '<div class="tab-pane fade" id="styling">'; // intro info $htmlShareButtonsForm .= '<blockquote><p>Use the options below to choose your favourite button set and how it should appear. <strong>If you wish to upload your own custom images</strong> please select \'Custom\' from the Image Set dropdown.</p></blockquote>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-7">'; // IMAGES -------------------------------- $htmlShareButtonsForm .= '<div class="well">'; // heading $htmlShareButtonsForm .= '<h3>Images</h3>'; // placement $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_image_set', 'label' => 'Image set', 'tooltip' => 'Choose your favourite set of buttons, or set to custom to choose your own', 'selected' => $arrSettings['ssba_image_set'], 'options' => array('Arbenta' => 'arbenta', 'Custom' => 'custom', 'Metal' => 'metal', 'Pagepeel' => 'pagepeel', 'Plain' => 'plain', 'Retro' => 'retro', 'Ribbons' => 'ribbons', 'Simple' => 'simple', 'Somacro' => 'somacro')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // custom images well $htmlShareButtonsForm .= '<div id="ssba-custom-images" ' . ($arrSettings['ssba_image_set'] != 'custom' ? 'style="display: none;"' : NULL) . '>'; // loop through each button foreach ($arrButtons as $button => $arrButton) { // enable custom images $opts = array('form_group' => false, 'type' => 'image_upload', 'name' => 'ssba_custom_' . $button, 'label' => $arrButton['full_name'], 'tooltip' => 'Upload a custom ' . $arrButton['full_name'] . ' image', 'value' => $arrSettings['ssba_custom_' . $button]); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); } // close custom images $htmlShareButtonsForm .= '</div>'; // button size $opts = array('form_group' => false, 'type' => 'number_addon', 'addon' => 'px', 'placeholder' => '35', 'name' => 'ssba_size', 'label' => 'Button Size', 'tooltip' => 'Set the size of your buttons in pixels', 'value' => $arrSettings['ssba_size']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // alignment $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_align', 'label' => 'Alignment', 'tooltip' => 'Align your buttons the way you wish', 'selected' => $arrSettings['ssba_align'], 'options' => array('Left' => 'left', 'Centre' => 'center', 'Right' => 'right')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // padding $opts = array('form_group' => false, 'type' => 'number_addon', 'addon' => 'px', 'placeholder' => '10', 'name' => 'ssba_padding', 'label' => 'Padding', 'tooltip' => 'Apply some space around your images', 'value' => $arrSettings['ssba_padding']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close images well $htmlShareButtonsForm .= '</div>'; // SHARE TEXT STYLING -------------------------------- $htmlShareButtonsForm .= '<div class="well">'; // heading $htmlShareButtonsForm .= '<h3>Share Text</h3>'; // font colour $opts = array('form_group' => false, 'type' => 'colorpicker', 'name' => 'ssba_font_color', 'label' => 'Font Colour', 'tooltip' => 'Choose the colour of your share text', 'value' => $arrSettings['ssba_font_color']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // font family $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_font_family', 'label' => 'Font Family', 'tooltip' => 'Choose a font available or inherit the font from your website', 'selected' => $arrSettings['ssba_font_family'], 'options' => array('Reenie Beanie' => 'Reenie Beanie', 'Indie Flower' => 'Indie Flower', 'Inherit from my website' => '')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // font size $opts = array('form_group' => false, 'type' => 'number_addon', 'addon' => 'px', 'placeholder' => '20', 'name' => 'ssba_font_size', 'label' => 'Font Size', 'tooltip' => 'Set the size of the share text in pixels', 'value' => $arrSettings['ssba_font_size']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // font weight $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_font_weight', 'label' => 'Font Weight', 'tooltip' => 'Set the weight of the share text', 'selected' => $arrSettings['ssba_font_weight'], 'options' => array('Bold' => 'bold', 'Normal' => 'normal', 'Light' => 'light')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // text placement $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_text_placement', 'label' => 'Text placement', 'tooltip' => 'Choose where you want your text to be displayed, in relation to the buttons', 'selected' => $arrSettings['ssba_text_placement'], 'options' => array('Above' => 'above', 'Left' => 'left', 'Right' => 'right', 'Below' => 'below')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close share text well $htmlShareButtonsForm .= '</div>'; // CONTAINER TEXT STYLING -------------------------------- $htmlShareButtonsForm .= '<div class="well">'; // heading $htmlShareButtonsForm .= '<h3>Container</h3>'; // container padding $opts = array('form_group' => false, 'type' => 'number_addon', 'addon' => 'px', 'placeholder' => '10', 'name' => 'ssba_div_padding', 'label' => 'Container Padding', 'tooltip' => 'Add some padding to your share container', 'value' => $arrSettings['ssba_div_padding']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // div background colour $opts = array('form_group' => false, 'type' => 'colorpicker', 'name' => 'ssba_div_background', 'label' => 'Container Background Colour', 'tooltip' => 'Choose the colour of your share container', 'value' => $arrSettings['ssba_div_background']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // div border colour $opts = array('form_group' => false, 'type' => 'colorpicker', 'name' => 'ssba_div_border', 'label' => 'Container Border Colour', 'tooltip' => 'Choose the colour of your share container border', 'value' => $arrSettings['ssba_div_border']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // container border width $opts = array('form_group' => false, 'type' => 'number_addon', 'addon' => 'px', 'placeholder' => '1', 'name' => 'ssba_border_width', 'label' => 'Container Border Width', 'tooltip' => 'Set the width of the share container border', 'value' => $arrSettings['ssba_border_width']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // rounded container corners $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_div_rounded_corners', 'label' => 'Rounded Container Corners', 'tooltip' => 'Switch on to enable rounded corners for your share container', 'value' => 'Y', 'checked' => $arrSettings['ssba_div_rounded_corners'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close container well $htmlShareButtonsForm .= '</div>'; // close col $htmlShareButtonsForm .= '</div>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-5">'; // plus plug $htmlShareButtonsForm .= '<div class="well">'; $htmlShareButtonsForm .= '<h2>Get responsive</h2>'; $htmlShareButtonsForm .= '<p class="lead">Looking for <strong>fixed</strong> and <strong>responsive</strong> share buttons?</p>'; $htmlShareButtonsForm .= '<p>With <strong>Simple Share Buttons Plus</strong> you can pick from 10 different styles, that are all <strong>mobile-responsive</strong>. You can also pick icon/button colours and their hover colours!</p>'; $htmlShareButtonsForm .= '<img class="ssba-responsive-img" src="' . plugins_url() . '/simple-share-buttons-adder/images/simple-share-buttons-mockups.png' . '" />'; $htmlShareButtonsForm .= '<div class="text-center ssba-spacer"><span class="text-20 label label-success">Only $10</span></div>'; $htmlShareButtonsForm .= '<a href="https://simplesharebuttons.com/plus/?utm_source=adder&utm_medium=plugin_ad&utm_campaign=product&utm_content=styling_tab" target="_blank"><span class="ssba-spacer btn btn-block btn-primary">Get Plus!</span></a>'; $htmlShareButtonsForm .= '<div class="ssba-spacer"></div>'; $htmlShareButtonsForm .= '</div>'; // close col $htmlShareButtonsForm .= '</div>'; // close share buttons tab $htmlShareButtonsForm .= '</div>'; //====================================================================== // COUNTERS //====================================================================== $htmlShareButtonsForm .= '<div class="tab-pane fade" id="counters">'; // intro info $htmlShareButtonsForm .= '<blockquote><p>You can tweak share counter settings to your liking here.</p></blockquote>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-7">'; // share count $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_show_share_count', 'label' => 'Share Count', 'tooltip' => 'Check the box if you wish to enable share counts. Enabling this option will slow down the loading of any pages that use share buttons', 'value' => 'Y', 'checked' => $arrSettings['ssba_show_share_count'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // show count once $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_share_count_once', 'label' => 'Show Once', 'tooltip' => 'This option is recommended, it deactivates share counts for categories and archives allowing them to load more quickly', 'value' => 'Y', 'checked' => $arrSettings['ssba_share_count_once'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // share counters style $opts = array('form_group' => false, 'type' => 'select', 'name' => 'ssba_share_count_style', 'label' => 'Counters Style', 'tooltip' => 'Pick a setting to style the share counters', 'selected' => $arrSettings['ssba_share_count_style'], 'options' => array('Default' => 'default', 'White' => 'white', 'Blue' => 'blue')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // newsharecounts.com enable $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'twitter_newsharecounts', 'label' => 'newsharecounts.com Counts for Twitter', 'tooltip' => 'Switch on to enable the use of the newsharecounts.com API for Twitter share counts', 'value' => 'Y', 'checked' => $arrSettings['twitter_newsharecounts'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // info $htmlShareButtonsForm .= '<p>You shall need to follow the instructions here before enabling this feature - <a target="_blank" href="http://newsharecounts.com/">newsharecounts.com</a>'; // open sharedcount well $htmlShareButtonsForm .= '<div class="well">'; // sharedcount heading $htmlShareButtonsForm .= '<h3>sharedcount.com</h3>'; $htmlShareButtonsForm .= '<p>Only necessary if you are experiencing issues with Facebook share counts. <a href="https://admin.sharedcount.com/admin/signup.php" target="_blank">Signup for your free account here</a>.</p>'; // sharedcount enable $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'sharedcount_enabled', 'label' => 'Enable sharedcount.com API', 'tooltip' => 'Enable if you wish to enable the use of the sharedcount.com API', 'value' => 'Y', 'checked' => $arrSettings['sharedcount_enabled'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // sharedcount plan $opts = array('form_group' => false, 'type' => 'select', 'name' => 'sharedcount_plan', 'label' => 'sharedcount.com plan', 'tooltip' => 'Select your sharedcount.com plan', 'selected' => $arrSettings['sharedcount_plan'], 'options' => array('Free' => 'free', 'Plus' => 'plus', 'Business' => 'business')); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // sharedcount api key $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => '9b17c12712c691491ef95f46c51ce3917118fdf9', 'name' => 'sharedcount_api_key', 'label' => 'sharedcount.com API Key', 'tooltip' => 'Add some text included in an email when people share that way', 'value' => $arrSettings['sharedcount_api_key']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close well $htmlShareButtonsForm .= '</div>'; // close col $htmlShareButtonsForm .= '</div>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-5">'; // plus plug $htmlShareButtonsForm .= '<div class="well">'; $htmlShareButtonsForm .= '<h2>Get speed and accuracy</h2>'; $htmlShareButtonsForm .= '<p class="lead">Do you want <strong>fast</strong> and <strong>consistent share counts</strong>?</p>'; $htmlShareButtonsForm .= '<p>With <strong>Simple Share Buttons Plus</strong> share counts are saved for the length of time you set, drastically speeding up page load time. Plus also comes with use of the SSB API for <a href="https://simplesharebuttons.com/plus/features/api/"><strong>consistent Facebook share counts</strong></a></p>'; $htmlShareButtonsForm .= '<img class="ssba-responsive-img" src="' . plugins_url() . '/simple-share-buttons-adder/images/simple-share-buttons-mockups.png' . '" />'; $htmlShareButtonsForm .= '<div class="text-center ssba-spacer"><span class="text-20 label label-success">Only $10</span></div>'; $htmlShareButtonsForm .= '<a href="https://simplesharebuttons.com/plus/?utm_source=adder&utm_medium=plugin_ad&utm_campaign=product&utm_content=counters_tab" target="_blank"><span class="ssba-spacer btn btn-block btn-primary">Get Plus!</span></a>'; $htmlShareButtonsForm .= '<div class="ssba-spacer"></div>'; $htmlShareButtonsForm .= '</div>'; // close col $htmlShareButtonsForm .= '</div>'; // close share buttons tab $htmlShareButtonsForm .= '</div>'; //====================================================================== // ADVANCED //====================================================================== $htmlShareButtonsForm .= '<div class="tab-pane fade" id="advanced">'; // intro info $htmlShareButtonsForm .= '<blockquote><p>You\'ll find a number of advanced and miscellaneous options below, to get your share buttons functioning how you would like.</p></blockquote>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-7">'; // link to ssb $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_link_to_ssb', 'label' => 'Share Text Link', 'tooltip' => 'Enabling this will set your share text as a link to simplesharebuttons.com to help others learn of the plugin', 'value' => 'Y', 'checked' => $arrSettings['ssba_link_to_ssb'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // content priority $opts = array('form_group' => false, 'type' => 'number', 'placeholder' => '10', 'name' => 'ssba_content_priority', 'label' => 'Content Priority', 'tooltip' => 'Set the priority for your share buttons within your content. 1-10, default is 10', 'value' => $arrSettings['ssba_content_priority']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // share in new window $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_share_new_window', 'label' => 'Open links in a new window', 'tooltip' => 'Disabling this will make links open in the same window', 'value' => 'Y', 'checked' => $arrSettings['ssba_share_new_window'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // nofollow $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_rel_nofollow', 'label' => 'Add rel="nofollow"', 'tooltip' => 'Enable this to add nofollow to all share links', 'value' => 'Y', 'checked' => $arrSettings['ssba_rel_nofollow'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // widget share text $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'Keeping sharing simple...', 'name' => 'ssba_widget_text', 'label' => 'Widget Share Text', 'tooltip' => 'Add custom share text when used as a widget', 'value' => $arrSettings['ssba_widget_text']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // email share text $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'Share by email...', 'name' => 'ssba_email_message', 'label' => 'Email Text', 'tooltip' => 'Add some text included in an email when people share that way', 'value' => $arrSettings['ssba_email_message']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // facebook app id $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => '123456789123', 'name' => 'facebook_app_id', 'label' => 'Facebook App ID', 'tooltip' => 'Enter your Facebook App ID, e.g. 123456789123', 'value' => $arrSettings['facebook_app_id'], 'disabled' => $arrSettings['accepted_sharethis_terms'] != 'Y' ? 'disabled' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // info $htmlShareButtonsForm .= '<p>You shall need to follow the instructions here before enabling this feature - <a target="_blank" href="https://developers.facebook.com/docs/apps/register">https://developers.facebook.com/docs/apps/register</a></p>'; // facebook insights $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'facebook_insights', 'label' => 'Facebook Insights', 'tooltip' => 'Enable this feature to enable Facebook Insights', 'value' => 'Y', 'checked' => $arrSettings['facebook_insights'] == 'Y' ? 'checked' : null, 'disabled' => $arrSettings['accepted_sharethis_terms'] != 'Y' ? 'disabled' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // info $htmlShareButtonsForm .= '<p>You shall need have created and added a Facebook App ID above to make use of this feature</p>'; // twitter share text $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'Shared by Twitter...', 'name' => 'ssba_twitter_text', 'label' => 'Twitter Text', 'tooltip' => 'Add some custom text for when people share via Twitter', 'value' => $arrSettings['ssba_twitter_text']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // flattr user id $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'davidsneal', 'name' => 'ssba_flattr_user_id', 'label' => 'Flattr User ID', 'tooltip' => 'Enter your Flattr ID, e.g. davidsneal', 'value' => $arrSettings['ssba_flattr_user_id']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // flattr url $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'https://simplesharebuttons.com', 'name' => 'ssba_flattr_url', 'label' => 'Flattr URL', 'tooltip' => 'This option is perfect for dedicated sites, e.g. https://simplesharebuttons.com', 'value' => $arrSettings['ssba_flattr_url']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // buffer text $opts = array('form_group' => false, 'type' => 'text', 'placeholder' => 'Shared by Buffer...', 'name' => 'ssba_buffer_text', 'label' => 'Custom Buffer Text', 'tooltip' => 'Add some custom text for when people share via Buffer', 'value' => $arrSettings['ssba_buffer_text']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // pin featured images $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_pinterest_featured', 'label' => 'Pin Featured Images', 'tooltip' => 'Force the use of featured images for posts/pages when pinning', 'value' => 'Y', 'checked' => $arrSettings['ssba_pinterest_featured'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // default pinterest image $opts = array('form_group' => false, 'type' => 'image_upload', 'name' => 'ssba_default_pinterest', 'label' => 'Default Pinterest Image', 'tooltip' => 'Upload a default Pinterest image', 'value' => $arrSettings['ssba_default_pinterest']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close col $htmlShareButtonsForm .= '</div>'; // COLUMN -------------------------------- $htmlShareButtonsForm .= '<div class="col-sm-5">'; // plus plug $htmlShareButtonsForm .= '<div class="well">'; $htmlShareButtonsForm .= '<h2>Get even more</h2>'; $htmlShareButtonsForm .= '<p class="lead">Hoping for <strong>even more</strong> features?</p>'; $htmlShareButtonsForm .= '<p>With <strong>Simple Share Buttons Plus</strong> there is an ever-growing \'Advanced\' features section, including <strong>bit.ly</strong> URL shortening, <strong>Google Analytics Event Tracking</strong> and <strong>Share-Meta</strong> Functionality.</p>'; $htmlShareButtonsForm .= '<img class="ssba-responsive-img" src="' . plugins_url() . '/simple-share-buttons-adder/images/simple-share-buttons-mockups.png' . '" />'; $htmlShareButtonsForm .= '<div class="text-center ssba-spacer"><span class="text-20 label label-success">Only $10</span></div>'; $htmlShareButtonsForm .= '<a href="https://simplesharebuttons.com/plus/?utm_source=adder&utm_medium=plugin_ad&utm_campaign=product&utm_content=advanced_tab" target="_blank"><span class="ssba-spacer btn btn-block btn-primary">Get Plus!</span></a>'; $htmlShareButtonsForm .= '<div class="ssba-spacer"></div>'; $htmlShareButtonsForm .= '</div>'; // close col $htmlShareButtonsForm .= '</div>'; // close share buttons tab $htmlShareButtonsForm .= '</div>'; //====================================================================== // ADDITIONAL CSS //====================================================================== $htmlShareButtonsForm .= '<div class="tab-pane fade" id="css_additional">'; // intro info $htmlShareButtonsForm .= '<blockquote><p>The contents of the text area below will be appended to Simple Share Button Adder\'s CSS.</p></blockquote>'; // column for padding $htmlShareButtonsForm .= '<div class="col-sm-12">'; // additional css $opts = array('form_group' => false, 'type' => 'textarea', 'rows' => '15', 'class' => 'code-font', 'name' => 'ssba_additional_css', 'label' => 'Additional CSS', 'tooltip' => 'Add your own additional CSS if you wish', 'value' => $arrSettings['ssba_additional_css']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close column $htmlShareButtonsForm .= '</div>'; // close additional css $htmlShareButtonsForm .= '</div>'; //====================================================================== // CUSTOM CSS //====================================================================== $htmlShareButtonsForm .= '<div class="tab-pane fade" id="css_custom">'; // intro info $htmlShareButtonsForm .= '<blockquote><p>If you want to take over control of your share buttons\' CSS entirely, turn on the switch below and enter your custom CSS. <strong>ALL of Simple Share Buttons Adder\'s CSS will be disabled</strong>.</p></blockquote>'; // column for padding $htmlShareButtonsForm .= '<div class="col-sm-12">'; // enable custom css $opts = array('form_group' => false, 'type' => 'checkbox', 'name' => 'ssba_custom_styles_enabled', 'label' => 'Enable Custom CSS', 'tooltip' => 'Switch on to disable all SSBA styles and use your own custom CSS', 'value' => 'Y', 'checked' => $arrSettings['ssba_custom_styles_enabled'] == 'Y' ? 'checked' : null); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // custom css $opts = array('form_group' => false, 'type' => 'textarea', 'rows' => '15', 'class' => 'code-font', 'name' => 'ssba_custom_styles', 'label' => 'Custom CSS', 'tooltip' => 'Enter in your own custom CSS for your share buttons', 'value' => $arrSettings['ssba_custom_styles']); $htmlShareButtonsForm .= $ssbpForm->ssbp_input($opts); // close column $htmlShareButtonsForm .= '</div>'; // close custom css $htmlShareButtonsForm .= '</div>'; // close tab content div $htmlShareButtonsForm .= '</div>'; // close off form with save button $htmlShareButtonsForm .= $ssbpForm->close(); // add footer $htmlShareButtonsForm .= ssba_admin_footer(); echo $htmlShareButtonsForm; }
function ssba_settings() { // check if user has the rights to manage options if (!current_user_can('manage_options')) { // permissions message wp_die(__('You do not have sufficient permissions to access this page.')); } // if a post has been made if (isset($_POST['ssbaData'])) { // get posted data $ssbaPost = $_POST['ssbaData']; parse_str($ssbaPost, $ssbaPost); // if the nonce doesn't check out... if (!isset($ssbaPost['ssba_save_nonce']) || !wp_verify_nonce($ssbaPost['ssba_save_nonce'], 'ssba_save_settings')) { die('There was no nonce provided, or the one provided did not verify.'); } // prepare array $arrOptions = array('ssba_image_set' => $ssbaPost['ssba_image_set'], 'ssba_size' => $ssbaPost['ssba_size'], 'ssba_pages' => isset($ssbaPost['ssba_pages']) ? $ssbaPost['ssba_pages'] : NULL, 'ssba_posts' => isset($ssbaPost['ssba_posts']) ? $ssbaPost['ssba_posts'] : NULL, 'ssba_cats_archs' => isset($ssbaPost['ssba_cats_archs']) ? $ssbaPost['ssba_cats_archs'] : NULL, 'ssba_homepage' => isset($ssbaPost['ssba_homepage']) ? $ssbaPost['ssba_homepage'] : NULL, 'ssba_excerpts' => isset($ssbaPost['ssba_excerpts']) ? $ssbaPost['ssba_excerpts'] : NULL, 'ssba_align' => isset($ssbaPost['ssba_align']) ? $ssbaPost['ssba_align'] : NULL, 'ssba_padding' => $ssbaPost['ssba_padding'], 'ssba_before_or_after' => $ssbaPost['ssba_before_or_after'], 'ssba_additional_css' => $ssbaPost['ssba_additional_css'], 'ssba_custom_styles' => $ssbaPost['ssba_custom_styles'], 'ssba_custom_styles_enabled' => $ssbaPost['ssba_custom_styles_enabled'], 'ssba_email_message' => stripslashes_deep($ssbaPost['ssba_email_message']), 'ssba_twitter_text' => stripslashes_deep($ssbaPost['ssba_twitter_text']), 'ssba_buffer_text' => stripslashes_deep($ssbaPost['ssba_buffer_text']), 'ssba_flattr_user_id' => stripslashes_deep($ssbaPost['ssba_flattr_user_id']), 'ssba_flattr_url' => stripslashes_deep($ssbaPost['ssba_flattr_url']), 'ssba_share_new_window' => isset($ssbaPost['ssba_share_new_window']) ? $ssbaPost['ssba_share_new_window'] : NULL, 'ssba_link_to_ssb' => isset($ssbaPost['ssba_link_to_ssb']) ? $ssbaPost['ssba_link_to_ssb'] : NULL, 'ssba_show_share_count' => isset($ssbaPost['ssba_show_share_count']) ? $ssbaPost['ssba_show_share_count'] : NULL, 'ssba_share_count_style' => $ssbaPost['ssba_share_count_style'], 'ssba_share_count_css' => $ssbaPost['ssba_share_count_css'], 'ssba_share_count_once' => isset($ssbaPost['ssba_share_count_once']) ? $ssbaPost['ssba_share_count_once'] : NULL, 'ssba_widget_text' => $ssbaPost['ssba_widget_text'], 'ssba_rel_nofollow' => isset($ssbaPost['ssba_rel_nofollow']) ? $ssbaPost['ssba_rel_nofollow'] : NULL, 'ssba_default_pinterest' => isset($ssbaPost['ssba_default_pinterest']) ? $ssbaPost['ssba_default_pinterest'] : NULL, 'ssba_pinterest_featured' => isset($ssbaPost['ssba_pinterest_featured']) ? $ssbaPost['ssba_pinterest_featured'] : NULL, 'ssba_content_priority' => isset($ssbaPost['ssba_content_priority']) ? $ssbaPost['ssba_content_priority'] : NULL, 'ssba_div_padding' => $ssbaPost['ssba_div_padding'], 'ssba_div_rounded_corners' => isset($ssbaPost['ssba_div_rounded_corners']) ? $ssbaPost['ssba_div_rounded_corners'] : NULL, 'ssba_border_width' => $ssbaPost['ssba_border_width'], 'ssba_div_border' => $ssbaPost['ssba_div_border'], 'ssba_div_background' => $ssbaPost['ssba_div_background'], 'ssba_share_text' => stripslashes_deep($ssbaPost['ssba_share_text']), 'ssba_text_placement' => $ssbaPost['ssba_text_placement'], 'ssba_font_family' => $ssbaPost['ssba_font_family'], 'ssba_font_color' => $ssbaPost['ssba_font_color'], 'ssba_font_size' => $ssbaPost['ssba_font_size'], 'ssba_font_weight' => $ssbaPost['ssba_font_weight'], 'ssba_selected_buttons' => $ssbaPost['ssba_selected_buttons']); // prepare array of buttons $arrButtons = json_decode(get_option('ssba_buttons'), true); // loop through each button foreach ($arrButtons as $button => $arrButton) { // add custom button to array of options $arrOptions['ssba_custom_' . $button] = $ssbaPost['ssba_custom_' . $button]; } // save the settings ssba_update_options($arrOptions); // return success return true; } // include then run the upgrade script include_once plugin_dir_path(SSBA_FILE) . '/inc/ssba_admin_panel.php'; // query the db for current ssba settings $arrSettings = get_ssba_settings(); // --------- ADMIN PANEL ------------ // ssba_admin_panel($arrSettings); }
function upgrade_ssba($arrSettings, $version) { // if version is less than 6.0.5 if ($version < '6.0.5') { // ensure excerpts are set add_option('ssba_excerpts', ''); // add print button add_option('ssba_custom_print', ''); // new for 3.8 add_option('ssba_widget_text', ''); add_option('ssba_rel_nofollow', ''); // added pre 4.5, added in 4.6 to fix notice add_option('ssba_rel_nofollow', ''); // added in 5.0 add_option('ssba_custom_vk', ''); add_option('ssba_custom_yummly', ''); // added in 5.2 add_option('ssba_default_pinterest', ''); // added in 5.5 add_option('ssba_pinterest_featured', ''); // added in 5.7 // additional CSS field add_option('ssba_additional_css', ''); // empty custom CSS var and option $customCSS = ''; add_option('ssba_custom_styles_enabled', ''); // if some custom styles are in place if ($arrSettings['ssba_custom_styles'] != '') { $customCSS .= $arrSettings['ssba_custom_styles']; update_option('ssba_custom_styles_enabled', 'Y'); } // if some custom share count styles are in place if ($arrSettings['ssba_share_count_css'] != '') { $customCSS .= $arrSettings['ssba_share_count_css']; update_option('ssba_custom_styles_enabled', 'Y'); } // update custom CSS option update_option('ssba_custom_styles', $customCSS); // content priority add_option('ssba_content_priority', '10'); } // if version is less than 6.0.6 if ($version < '6.0.6') { // get old settings $oldSettings = get_old_ssba_settings(); // json encode old settings $jsonSettings = json_encode($oldSettings); // insert all options for ssba as json add_option('ssba_settings', $jsonSettings); // delete old options ssba_delete_old_options(); } // if version is less than 6.1.3 if ($version < '6.1.3') { // new settings $new = array('sharedcount_enabled' => '', 'sharedcount_api_key' => '', 'sharedcount_plan' => 'free'); // update settings ssba_update_options($new); } // if version is less than 6.1.5 if ($version < '6.1.5') { // new settings $new = array('twitter_newsharecounts' => ''); // update settings ssba_update_options($new); } // if version is less than 6.2.0 if ($version < '6.2.0') { // new settings $new = array('facebook_insights' => '', 'facebook_app_id' => '', 'accepted_sharethis_terms' => ''); // update settings ssba_update_options($new); } // button helper array ssba_button_helper_array(); // update version number update_option('ssba_version', SSBA_VERSION); }