Skip to content

Commit

Permalink
Plugin updated to version 4.15
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurGareginyan committed Aug 8, 2017
1 parent 6adf824 commit 9a8e2a3
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 188 deletions.
164 changes: 82 additions & 82 deletions inc/css/admin.css

Large diffs are not rendered by default.

79 changes: 66 additions & 13 deletions inc/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,93 @@
* @uthor Arthur Gareginyan
* @link https://www.arthurgareginyan.com
* @copyright Copyright (c) 2016-2017 Arthur Gareginyan. All Rights Reserved.
* @since 4.12.1
* @since 4.15
*/


jQuery(document).ready(function($) {

"use strict";

// Remove the "successful" message after 3 seconds
if (".updated") {
// Remove the 'successful' message after 3 seconds
if ('.updated') {
setTimeout(function() {
$(".updated").fadeOut();
$('.updated').fadeOut();
}, 3000);
}

// Enable Bootstrap Checkboxes
$(':checkbox').checkboxpicker();

// Dynamic content
$( ".include-tab-author" ).load( "https://mycyberuniverse.com/public-files/dynamic-content/page-for-include.html #include-tab-author" );
$( ".include-tab-support" ).load( "https://mycyberuniverse.com/public-files/dynamic-content/page-for-include.html #include-tab-support" );
$( ".include-tab-family" ).load( "https://mycyberuniverse.com/public-files/dynamic-content/page-for-include.html #include-tab-family" );
$( ".additional-css" ).load( "https://mycyberuniverse.com/public-files/dynamic-content/styles.html" );
// Add dynamic content to page tabs. Needed for having an up to date content.
$('.include-tab-author').load('https://www.spacexchimp.com/assets/dynamic-content/plugins.html #include-tab-author');
$('.include-tab-support').load('https://www.spacexchimp.com/assets/dynamic-content/plugins.html #include-tab-support');
$('.include-tab-store').load('https://www.spacexchimp.com/assets/dynamic-content/plugins.html #include-tab-store');
$('.include-banner').load('https://www.spacexchimp.com/assets/dynamic-content/plugins.html #include-banner');

// Add questions and answers into spoilers and color them in different colors
$(".panel-group .panel").each(function(i) {
$( ".question-" + (i+1) ).appendTo( $("h4", this) );
$( ".answer-" + (i+1) ).appendTo( $(".panel-body", this) );
$('.panel-group .panel').each(function(i) {
$('.question-' + (i+1) ).appendTo( $('h4', this) );
$('.answer-' + (i+1) ).appendTo( $('.panel-body', this) );

if ( $(this).find("h4 div").hasClass('question-red') ) {
if ( $(this).find('h4 div').hasClass('question-red') ) {
$(this).addClass('panel-danger');
} else {
$(this).addClass('panel-info');
}
});

// Live preview
$('.new_tab').on('change', function() {
var val = $(this).val();
var position = $(this).next().children().hasClass('btn-success');
$('#preview .smbt-social-icons a').each(function( index ) {
if (position === true) {
$(this).attr('target','_blank');
} else {
$(this).removeAttr('target');
}
});
});

$('.tooltips').on('change', function() {
var val = $(this).val();
var position = $(this).next().children().hasClass('btn-success');
$('#preview .smbt-social-icons a').each(function( index ) {
var text = '';
if (position === true) {
text = $(this).attr('title');
$(this).attr('data-toggle','tooltip');
$(this).attr('data-original-title',text);
} else {
text = $(this).attr('data-original-title');
$(this).attr('title',text);
$(this).removeAttr('data-toggle');
$(this).removeAttr('data-original-title');
}
});
});

function LiveInlineStyles() {
var icon_size = $('.icon-size').val() || '64';
var margin = $('.margin-right').val() / 2 || '5';
icon_size = 'width:' + icon_size + 'px !important; height:' + icon_size + 'px !important;';
margin = 'margin:' + margin + 'px !important;';
$('#preview .smbt-social-icons img').attr('style',icon_size + margin);
}

$('.icon-size').change(function() {
LiveInlineStyles();
});

$('.margin-right').change(function() {
LiveInlineStyles();
});

$('.alignment').change(function() {
var alignment = $('input[type=radio]:checked', '.alignment').val() || 'center';
alignment = 'text-align:' + alignment + ' !important;';
$('#preview .smbt-social-icons').attr('style',alignment);
});

});
44 changes: 14 additions & 30 deletions inc/php/enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Base for the _load_scripts hook
*
* @since 4.11
* @since 4.15
*/
function smbtoolbar_load_scripts_base( $options ) {

Expand All @@ -25,34 +25,18 @@ function smbtoolbar_load_scripts_base( $options ) {
// Style sheet
wp_enqueue_style( $prefix . '-frontend-css', $url . 'inc/css/frontend.css' );

// Size of icons
$icon_size = esc_textarea( $options['icon-size'] );
if ( empty( $icon_size ) ) {
$icon_size = "64";
}

// Space between icons
$margin_right = esc_textarea( $options['margin-right'] );
if ( empty( $margin_right ) ) {
$margin_right = "10";
}

// Alignment of toolbar
if ( !empty( $options['alignment'] ) ) {
$alignment = $options['alignment'];
} else {
$alignment = 'center';
}

// Dynamic CSS. Create CSS and injected it into the stylesheet
$icon_size = !empty( $options['icon-size'] ) ? esc_textarea( $options['icon-size'] ) : '64';
$margin = !empty( $options['margin-right'] ) ? esc_textarea( $options['margin-right'] ) : '10';
$alignment = !empty( $options['alignment'] ) ? $options['alignment'] : 'center';
$custom_css = "
.smbt-social-icons {
text-align: " . $alignment . " !important;
}
.smbt-social-icons li img {
width: " . $icon_size . "px !important;
height: " . $icon_size . "px !important;
margin: " . ( $margin_right / 2 ) . "px !important;
margin: " . ( $margin / 2 ) . "px !important;
}
";
wp_add_inline_style( $prefix . '-frontend-css', $custom_css );
Expand All @@ -62,7 +46,7 @@ function smbtoolbar_load_scripts_base( $options ) {
/**
* Load scripts and style sheet for settings page
*
* @since 4.11
* @since 4.15
*/
function smbtoolbar_load_scripts_admin( $hook ) {

Expand All @@ -78,15 +62,9 @@ function smbtoolbar_load_scripts_admin( $hook ) {
return;
}

// Read options from BD
// Read options from database
$options = get_option( $settings . '_settings' );

// Style sheet
wp_enqueue_style( $prefix . '-admin-css', $url . 'inc/css/admin.css' );

// JavaScript
wp_enqueue_script( $prefix . '-admin-js', $url . 'inc/js/admin.js', array(), false, true );

// Bootstrap library
wp_enqueue_style( $prefix . '-bootstrap-css', $url . 'inc/lib/bootstrap/bootstrap.css' );
wp_enqueue_style( $prefix . '-bootstrap-theme-css', $url . 'inc/lib/bootstrap/bootstrap-theme.css' );
Expand All @@ -95,6 +73,12 @@ function smbtoolbar_load_scripts_admin( $hook ) {
// Other libraries
wp_enqueue_script( $prefix . '-bootstrap-checkbox-js', $url . 'inc/lib/bootstrap-checkbox.js' );

// Style sheet
wp_enqueue_style( $prefix . '-admin-css', $url . 'inc/css/admin.css' );

// JavaScript
wp_enqueue_script( $prefix . '-admin-js', $url . 'inc/js/admin.js', array(), false, true );

// Call the function that contain a basis of scripts
smbtoolbar_load_scripts_base( $options );

Expand All @@ -114,7 +98,7 @@ function smbtoolbar_load_scripts_frontend() {
$url = SMEDIABT_URL;
$settings = SMEDIABT_SETTINGS;

// Read options from BD
// Read options from database
$options = get_option( $settings . '_settings' );

// Call the function that contain a basis of scripts
Expand Down
63 changes: 17 additions & 46 deletions inc/php/functional.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,18 @@
defined( 'ABSPATH' ) or die( "Restricted access!" );

/**
* Render fields for saving social media data to BD
* Render fields for saving social media data to database
*
* @since 4.6
* @since 4.15
*/
function smbtoolbar_media( $name, $label, $placeholder, $help=null, $link=null ) {

// Read options from BD
// Read options from database and declare variables
$options = get_option( SMEDIABT_SETTINGS . '_settings' );

if ( !empty( $options["media"][$name]["content"] ) ) {
$value = esc_textarea( $options["media"][$name]["content"] );
} else {
$value = "";
}
$value = !empty( $options["media"][$name]["content"] ) ? esc_textarea( $options["media"][$name]["content"] ) : '';

// Generate the table
if ( !empty( $link ) ) {
$link_out = "<a href='$link' target='_blank'>$label</a>";
} else {
$link_out = "$label";
}
$link_out = !empty( $link ) ? "<a href='$link' target='_blank'>$label</a>" : "$label";

$label = "<input type='hidden' name='" . SMEDIABT_SETTINGS . "_settings[media][$name][label]' value='$label'>";
$slug = "<input type='hidden' name='" . SMEDIABT_SETTINGS . "_settings[media][$name][slug]' value='$name'>";
Expand Down Expand Up @@ -63,30 +54,21 @@ function smbtoolbar_media( $name, $label, $placeholder, $help=null, $link=null )
/**
* Render checkboxes and fields for saving settings data to database
*
* @since 4.6
* @since 4.15
*/
function smbtoolbar_setting( $name, $label, $help=null, $field=null, $placeholder=null, $size=null ) {

// Read options from BD
// Read options from database and declare variables
$options = get_option( SMEDIABT_SETTINGS . '_settings' );

if ( !empty( $options[$name] ) ) {
$value = esc_textarea( $options[$name] );
} else {
$value = "";
}
$value = !empty( $options[$name] ) ? esc_textarea( $options[$name] ) : '';

// Generate the table
if ( !empty( $options[$name] ) ) {
$checked = "checked='checked'";
} else {
$checked = "";
}
$checked = !empty( $options[$name] ) ? "checked='checked'" : '';

if ( $field == "check" ) {
$input = "<input type='checkbox' name='" . SMEDIABT_SETTINGS . "_settings[$name]' id='" . SMEDIABT_SETTINGS . "_settings[$name]' $checked >";
$input = "<input type='checkbox' name='" . SMEDIABT_SETTINGS . "_settings[$name]' id='" . SMEDIABT_SETTINGS . "_settings[$name]' $checked class='$name' >";
} elseif ( $field == "field" ) {
$input = "<input type='text' name='" . SMEDIABT_SETTINGS . "_settings[$name]' id='" . SMEDIABT_SETTINGS . "_settings[$name]' size='$size' value='$value' placeholder='$placeholder' >";
$input = "<input type='text' name='" . SMEDIABT_SETTINGS . "_settings[$name]' id='" . SMEDIABT_SETTINGS . "_settings[$name]' size='$size' value='$value' placeholder='$placeholder' class='$name' >";
}

// Put table to the variables $out and $help_out
Expand Down Expand Up @@ -116,33 +98,22 @@ function smbtoolbar_setting( $name, $label, $help=null, $field=null, $placeholde
/**
* Generate the buttons and make shortcode
*
* @since 4.6
* @since 4.15
*/
function smbtoolbar_tollbar() {

// Read options from BD
// Read options from database and declare variables
$options = get_option( SMEDIABT_SETTINGS . '_settings' );
$media = $options['media'];

// Open link in new tab
if ( !empty( $options['new_tab'] ) ) {
$new_tab = 'target="blank"';
} else {
$new_tab = '';
}
$new_tab = !empty( $options['new_tab'] ) ? 'target="blank"' : '';

// Enable Tolltips
if ( !empty( $options['tooltips'] ) ) {
$tooltips = 'data-toggle="tooltip"';
} else {
$tooltips = '';
}
$tooltips = !empty( $options['tooltips'] ) ? 'data-toggle="tooltip"' : '';

// Add a caption above of buttons
$caption = esc_textarea( $options['caption'] );
if ( empty( $caption ) ) {
$caption = "";
}
$caption = !empty( $options['caption'] ) ? esc_textarea( $options['caption'] ) : '';

// Generate buttons
$metatags_arr[] = '<ul class="smbt-social-icons">';
Expand Down Expand Up @@ -199,7 +170,7 @@ function smbtoolbar_tollbar() {

// Return the content of array
return $metatags_arr;

}

/**
Expand Down
4 changes: 2 additions & 2 deletions inc/php/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Hello message - Bootstrap Modal
*
* @since 4.12.1
* @since 4.15
*/
function smbtoolbar_hello_message() {

Expand All @@ -25,7 +25,7 @@ function smbtoolbar_hello_message() {
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<img src="https://mycyberuniverse.com/public-files/images/Arthur.png">
<img src="https://www.spacexchimp.com/assets/dynamic-content/images/avatar.png">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<p><?php _e( 'Hello. I\'m Arthur, the author of this plugin.', SMEDIABT_TEXT ); ?></p>
<p><?php printf(
Expand Down
8 changes: 4 additions & 4 deletions inc/php/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Render Settings Page
*
* @since 4.12.1
* @since 4.15
*/
function smbtoolbar_render_submenu_page() {

Expand Down Expand Up @@ -49,7 +49,7 @@ function smbtoolbar_render_submenu_page() {
<li><a href="#tab-faq" data-toggle="tab"><?php _e( 'F.A.Q.', $text ); ?></a></li>
<li><a href="#tab-author" data-toggle="tab"><?php _e( 'Author', $text ); ?></a></li>
<li><a href="#tab-support" data-toggle="tab"><?php _e( 'Support', $text ); ?></a></li>
<li><a href="#tab-family" data-toggle="tab"><?php _e( 'Family', $text ); ?></a></li>
<li><a href="#tab-store" data-toggle="tab"><?php _e( 'Store', $text ); ?></a></li>
</ul>
<!-- END-TABS NAVIGATION MENU -->

Expand Down Expand Up @@ -205,8 +205,8 @@ function smbtoolbar_render_submenu_page() {
<!-- END-TAB 5 -->

<!-- TAB 6 -->
<div class="tab-page fade" id="tab-family">
<div class="include-tab-family"></div>
<div class="tab-page fade" id="tab-store">
<div class="include-tab-store"></div>
</div>
<!-- END-TAB 6 -->

Expand Down
Loading

0 comments on commit 9a8e2a3

Please sign in to comment.