Пример #1
0
function ssbl_settings()
{
    // check if user has the rights to manage options
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // if a post has been made
    if (isset($_POST['ssblData'])) {
        // get posted data
        $ssblPost = $_POST['ssblData'];
        parse_str($ssblPost, $ssblPost);
        // if the nonce doesn't check out...
        if (!isset($ssblPost['ssbl_save_nonce']) || !wp_verify_nonce($ssblPost['ssbl_save_nonce'], 'ssbl_save_settings')) {
            die('There was no nonce provided, or the one provided did not verify.');
        }
        // prepare array to save
        $arrOptions = array('pages' => isset($ssblPost['pages']) ? stripslashes_deep($ssblPost['pages']) : null, 'posts' => isset($ssblPost['posts']) ? stripslashes_deep($ssblPost['posts']) : null, 'share_text' => isset($ssblPost['share_text']) ? stripslashes_deep($ssblPost['share_text']) : null, 'image_set' => isset($ssblPost['image_set']) ? stripslashes_deep($ssblPost['image_set']) : null, 'selected_buttons' => isset($ssblPost['selected_buttons']) ? stripslashes_deep($ssblPost['selected_buttons']) : null);
        // save the settings
        ssbl_update_options($arrOptions);
        return true;
    }
    // include required admin view
    include_once SSBL_ROOT . '/system/views/ssbl_admin_panel.php';
    // get ssbl settings
    $ssbl_settings = get_ssbl_settings();
    // --------- ADMIN PANEL ------------ //
    ssbl_admin_panel($ssbl_settings);
}
Пример #2
0
function ssbl_show_share_buttons($content, $booShortCode = false, $atts = '')
{
    // globals
    global $post;
    // get ssbl settings
    $ssbl_settings = get_ssbl_settings();
    // variables
    $buttons = '';
    // placement on pages/posts/categories/archives/homepage
    if (!is_home() && !is_front_page() && is_page() && $ssbl_settings['pages'] == 'Y' || is_single() && $ssbl_settings['posts'] == 'Y' || $booShortCode == true) {
        // ssbl comment
        $buttons .= '<!-- Simple Share Buttons Light (v' . SSBL_VERSION . ') simplesharebuttons.com/light -->';
        // if running standard
        if ($booShortCode == false) {
            // get title and url
            $strPageTitle = get_the_title($post->ID);
            $urlCurrentPage = get_permalink($post->ID);
        } else {
            // if we're not viewing a post
            if (!is_single()) {
                // if a title has been provided
                if (isset($atts['title']) && $atts['title'] != '') {
                    // use the set title
                    $strPageTitle = $atts['title'];
                } else {
                    // get the page title
                    $strPageTitle = wp_title('', false);
                }
            } else {
                // set page title as set by user or get if needed
                $strPageTitle = isset($atts['title']) ? $atts['title'] : get_the_title();
            }
            // set the url as set by user or get if needed
            $urlCurrentPage = isset($atts['url']) ? $atts['url'] : ssbl_current_url();
        }
        // strip any unwanted tags from the page title
        $strPageTitle = esc_attr(strip_tags($strPageTitle));
        // get wrap
        $buttons .= '<div class="ssbl-wrap">';
        // ssbl div
        $buttons .= '<div class="ssbl-container">';
        // if there is some share text
        if ($ssbl_settings['share_text'] != '') {
            // add share text
            $buttons .= '<span class="ssbl-share-text">' . $ssbl_settings['share_text'] . '</span>';
        }
        // initiate class and get buttons
        $ssblButtons = new SSBL_Buttons($ssbl_settings, $strPageTitle, $urlCurrentPage);
        // add the buttons
        $buttons .= $ssblButtons->get_buttons();
        // close container div
        $buttons .= '</div>';
        // close wrap div
        $buttons .= '</div>';
        // adding shortcode buttons
        if ($booShortCode == true) {
            return $buttons;
        } else {
            // return buttons after content
            return $content . $buttons;
        }
    } else {
        // no buttons
        return $content;
    }
}
 / __| '_ \ / _` | '__/ _ \ '_ \| | | | __| __/ _ \| '_ \/ __|
 \__ \ | | | (_| | | |  __/ |_) | |_| | |_| || (_) | | | \__ \
 |___/_| |_|\__,_|_|  \___|_.__/ \__,_|\__|\__\___/|_| |_|___/
*/
//======================================================================
// 		CONSTANTS
//======================================================================
// set constants
define('SSBL_FILE', __FILE__);
define('SSBL_ROOT', dirname(__FILE__));
define('SSBL_VERSION', '0.0.2');
//======================================================================
// 		 SSBL SETTINGS
//======================================================================
// get ssbl settings
$ssbl_settings = get_ssbl_settings();
//======================================================================
// 		INCLUDES
//======================================================================
// db includes in case needed
include_once SSBL_ROOT . '/system/models/ssbl_database.php';
// frontend side functions
include_once SSBL_ROOT . '/system/controllers/ssbl_buttons.php';
//======================================================================
// 		ADMIN ONLY
//======================================================================
// register/deactivate/uninstall
register_activation_hook(__FILE__, 'ssbl_activate');
//register_deactivation_hook( __FILE__, 'ssbl_deactivate' );
register_uninstall_hook(__FILE__, 'ssbl_uninstall');
// ssbl admin area hook