YITH WooCommerce Zoom Magnifier - Version 1.0.1

Version Description

  • Optimized images
  • Updated internal framework
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Zoom Magnifier
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

README.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
4
  Tags: zoom, magnifier, woocommerce, products, themes, yit, e-commerce, shop
5
  Requires at least: 3.5.1
6
  Tested up to: 3.5.1
7
- Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -63,6 +63,11 @@ The size of the Zoom Image is automatically setted. If you want to change these
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
66
  = 1.0.0 =
67
 
68
  * Initial release
4
  Tags: zoom, magnifier, woocommerce, products, themes, yit, e-commerce, shop
5
  Requires at least: 3.5.1
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
63
 
64
  == Changelog ==
65
 
66
+ = 1.0.1 =
67
+
68
+ * Optimized images
69
+ * Updated internal framework
70
+
71
  = 1.0.0 =
72
 
73
  * Initial release
class.yith-wcmg.php CHANGED
@@ -39,7 +39,6 @@ if( !class_exists( 'YITH_WCMG' ) ) {
39
  * @since 1.0.0
40
  */
41
  public function __construct() {
42
- load_plugin_textdomain( 'yit', false, YITH_WCMG_DIR . 'languages/' );
43
 
44
  // actions
45
  add_action( 'init', array( $this, 'init' ) );
39
  * @since 1.0.0
40
  */
41
  public function __construct() {
 
42
 
43
  // actions
44
  add_action( 'init', array( $this, 'init' ) );
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Zoom Magnifier
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Zoom Magnifier enables you to add a zoom effect to product images.
6
- * Version: 1.0.0
7
  * Author: Your Inspiration Themes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
@@ -11,7 +11,7 @@
11
  *
12
  * @author Your Inspiration Themes
13
  * @package YITH WooCommerce Magnifier
14
- * @version 1.0.0
15
  */
16
  /* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
17
 
@@ -38,6 +38,8 @@ if( !defined('YITH_FUNCTIONS') ) {
38
  }
39
  if ( ! yit_is_woocommerce_active() ) return;
40
 
 
 
41
  define( 'YITH_WCMG', true );
42
  define( 'YITH_WCMG_URL', plugin_dir_url( __FILE__ ) );
43
  define( 'YITH_WCMG_DIR', plugin_dir_path( __FILE__ ) );
3
  * Plugin Name: YITH WooCommerce Zoom Magnifier
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Zoom Magnifier enables you to add a zoom effect to product images.
6
+ * Version: 1.0.1
7
  * Author: Your Inspiration Themes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
11
  *
12
  * @author Your Inspiration Themes
13
  * @package YITH WooCommerce Magnifier
14
+ * @version 1.0.1
15
  */
16
  /* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
17
 
38
  }
39
  if ( ! yit_is_woocommerce_active() ) return;
40
 
41
+ load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
42
+
43
  define( 'YITH_WCMG', true );
44
  define( 'YITH_WCMG_URL', plugin_dir_url( __FILE__ ) );
45
  define( 'YITH_WCMG_DIR', plugin_dir_path( __FILE__ ) );
yit-common/assets/css/yith-panel.css ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* typography */
2
+ .typography_container {
3
+ padding-bottom:0px;
4
+ }
5
+ .typography_container .option {
6
+ width: 100%;
7
+ }
8
+ .typography_container input {
9
+ float:left;
10
+ margin-right:14px;
11
+ }
12
+
13
+ .typography_container .select-wrapper {
14
+ float: left;
15
+ width: 150px;
16
+ margin-right: 10px;
17
+ margin-bottom: 0px !important;
18
+ }
19
+ .typography_container .select-wrapper.font-unit {
20
+ width: 61px;
21
+ }
22
+ .typography_container .ui-spinner-buttons {
23
+ top: 0px !important;
24
+ }
25
+ .typography_container .select-wrapper.font-style {
26
+ width: 93px;
27
+ }
28
+ .typography_container .select-wrapper select {
29
+ width:100%;
30
+ }
31
+
32
+ .typography_container .font-preview {
33
+ border: 1px dashed #ddd;
34
+ -webkit-border-radius: 10px;
35
+ -moz-border-radius: 10px;
36
+ border-radius: 10px;
37
+ margin: 10px 0;
38
+ padding: 20px;
39
+ position: relative;
40
+ }
41
+ .typography_container .font-preview .refresh_container {
42
+ background: rgba(255,255,255,0.82);
43
+ -webkit-border-radius: 10px;
44
+ -moz-border-radius: 10px;
45
+ border-radius: 10px;
46
+ position: absolute;
47
+ left: 0;
48
+ top: 0;
49
+ width: 100%;
50
+ height: 100%;
51
+ z-index: 0;
52
+ }
53
+ .typography_container button.refresh {
54
+ /*background: #F2F2F2 url(../images/white-grad.png) repeat-x scroll left top;*/
55
+ border: 1px solid #BBB;
56
+ -webkit-border-radius: 11px;
57
+ border-radius: 11px;
58
+ -moz-box-sizing: content-box;
59
+ -webkit-box-sizing: content-box;
60
+ box-sizing: content-box;
61
+ color: #464646;
62
+ cursor: pointer;
63
+ font-size: 12px!important;
64
+ line-height: 6px;
65
+ margin: -16px 0px 0px -105px;
66
+ padding: 3px 8px;
67
+ position: absolute;
68
+ text-shadow: rgba(255, 255, 255, 1) 0 1px 0;
69
+ text-decoration: none;
70
+ top: 50%;
71
+ left: 50%;
72
+ width: 108px;
73
+ height: 18px;
74
+ }
75
+ .typography_container button.refresh img {
76
+ margin-right: 5px;
77
+ vertical-align: middle;
78
+ }
yit-common/assets/js/google_fonts.json ADDED
@@ -0,0 +1 @@
 
1
+ {"items":["ABeeZee","Abel","Abril Fatface","Aclonica","Acme","Actor","Adamina","Advent Pro","Aguafina Script","Akronim","Aladin","Aldrich","Alef","Alegreya","Alegreya SC","Alex Brush","Alfa Slab One","Alice","Alike","Alike Angular","Allan","Allerta","Allerta Stencil","Allura","Almendra","Almendra Display","Almendra SC","Amarante","Amaranth","Amatic SC","Amethysta","Anaheim","Andada","Andika","Angkor","Annie Use Your Telescope","Anonymous Pro","Antic","Antic Didone","Antic Slab","Anton","Arapey","Arbutus","Arbutus Slab","Architects Daughter","Archivo Black","Archivo Narrow","Arimo","Arizonia","Armata","Artifika","Arvo","Asap","Asset","Astloch","Asul","Atomic Age","Aubrey","Audiowide","Autour One","Average","Average Sans","Averia Gruesa Libre","Averia Libre","Averia Sans Libre","Averia Serif Libre","Bad Script","Balthazar","Bangers","Basic","Battambang","Baumans","Bayon","Belgrano","Belleza","BenchNine","Bentham","Berkshire Swash","Bevan","Bigelow Rules","Bigshot One","Bilbo","Bilbo Swash Caps","Bitter","Black Ops One","Bokor","Bonbon","Boogaloo","Bowlby One","Bowlby One SC","Brawler","Bree Serif","Bubblegum Sans","Bubbler One","Buda:300","Buenard","Butcherman","Butterfly Kids","Cabin","Cabin Condensed","Cabin Sketch","Caesar Dressing","Cagliostro","Calligraffitti","Cambo","Candal","Cantarell","Cantata One","Cantora One","Capriola","Cardo","Carme","Carrois Gothic","Carrois Gothic SC","Carter One","Caudex","Cedarville Cursive","Ceviche One","Changa One","Chango","Chau Philomene One","Chela One","Chelsea Market","Chenla","Cherry Cream Soda","Cherry Swash","Chewy","Chicle","Chivo","Cinzel","Cinzel Decorative","Clicker Script","Coda","Coda Caption:800","Codystar","Combo","Comfortaa","Coming Soon","Concert One","Condiment","Content","Contrail One","Convergence","Cookie","Copse","Corben","Courgette","Cousine","Coustard","Covered By Your Grace","Crafty Girls","Creepster","Crete Round","Crimson Text","Croissant One","Crushed","Cuprum","Cutive","Cutive Mono","Damion","Dancing Script","Dangrek","Dawning of a New Day","Days One","Delius","Delius Swash Caps","Delius Unicase","Della Respira","Denk One","Devonshire","Didact Gothic","Diplomata","Diplomata SC","Domine","Donegal One","Doppio One","Dorsa","Dosis","Dr Sugiyama","Droid Sans","Droid Sans Mono","Droid Serif","Duru Sans","Dynalight","EB Garamond","Eagle Lake","Eater","Economica","Electrolize","Elsie","Elsie Swash Caps","Emblema One","Emilys Candy","Engagement","Englebert","Enriqueta","Erica One","Esteban","Euphoria Script","Ewert","Exo","Expletus Sans","Fanwood Text","Fascinate","Fascinate Inline","Faster One","Fasthand","Federant","Federo","Felipa","Fenix","Finger Paint","Fjalla One","Fjord One","Flamenco","Flavors","Fondamento","Fontdiner Swanky","Forum","Francois One","Freckle Face","Fredericka the Great","Fredoka One","Freehand","Fresca","Frijole","Fruktur","Fugaz One","GFS Didot","GFS Neohellenic","Gabriela","Gafata","Galdeano","Galindo","Gentium Basic","Gentium Book Basic","Geo","Geostar","Geostar Fill","Germania One","Gilda Display","Give You Glory","Glass Antiqua","Glegoo","Gloria Hallelujah","Goblin One","Gochi Hand","Gorditas","Goudy Bookletter 1911","Graduate","Grand Hotel","Gravitas One","Great Vibes","Griffy","Gruppo","Gudea","Habibi","Hammersmith One","Hanalei","Hanalei Fill","Handlee","Hanuman","Happy Monkey","Headland One","Henny Penny","Herr Von Muellerhoff","Holtwood One SC","Homemade Apple","Homenaje","IM Fell DW Pica","IM Fell DW Pica SC","IM Fell Double Pica","IM Fell Double Pica SC","IM Fell English","IM Fell English SC","IM Fell French Canon","IM Fell French Canon SC","IM Fell Great Primer","IM Fell Great Primer SC","Iceberg","Iceland","Imprima","Inconsolata","Inder","Indie Flower","Inika","Irish Grover","Istok Web","Italiana","Italianno","Jacques Francois","Jacques Francois Shadow","Jim Nightshade","Jockey One","Jolly Lodger","Josefin Sans","Josefin Slab","Joti One","Judson","Julee","Julius Sans One","Junge","Jura","Just Another Hand","Just Me Again Down Here","Kameron","Karla","Kaushan Script","Kavoon","Keania One","Kelly Slab","Kenia","Khmer","Kite One","Knewave","Kotta One","Koulen","Kranky","Kreon","Kristi","Krona One","La Belle Aurore","Lancelot","Lato","League Script","Leckerli One","Ledger","Lekton","Lemon","Libre Baskerville","Life Savers","Lilita One","Limelight","Linden Hill","Lobster","Lobster Two","Londrina Outline","Londrina Shadow","Londrina Sketch","Londrina Solid","Lora","Love Ya Like A Sister","Loved by the King","Lovers Quarrel","Luckiest Guy","Lusitana","Lustria","Macondo","Macondo Swash Caps","Magra","Maiden Orange","Mako","Marcellus","Marcellus SC","Marck Script","Margarine","Marko One","Marmelad","Marvel","Mate","Mate SC","Maven Pro","McLaren","Meddon","MedievalSharp","Medula One","Megrim","Meie Script","Merienda","Merienda One","Merriweather","Merriweather Sans","Metal","Metal Mania","Metamorphous","Metrophobic","Michroma","Milonga","Miltonian","Miltonian Tattoo","Miniver","Miss Fajardose","Modern Antiqua","Molengo","Molle:italic","Monda","Monofett","Monoton","Monsieur La Doulaise","Montaga","Montez","Montserrat","Montserrat Alternates","Montserrat Subrayada","Moul","Moulpali","Mountains of Christmas","Mouse Memoirs","Mr Bedfort","Mr Dafoe","Mr De Haviland","Mrs Saint Delafield","Mrs Sheppards","Muli","Mystery Quest","Neucha","Neuton","New Rocker","News Cycle","Niconne","Nixie One","Nobile","Nokora","Norican","Nosifer","Nothing You Could Do","Noticia Text","Noto Sans","Noto Serif","Nova Cut","Nova Flat","Nova Mono","Nova Oval","Nova Round","Nova Script","Nova Slim","Nova Square","Numans","Nunito","Odor Mean Chey","Offside","Old Standard TT","Oldenburg","Oleo Script","Oleo Script Swash Caps","Open Sans","Open Sans Condensed:300","Open Sans Condensed:300italic","Open Sans Condensed:700","Oranienbaum","Orbitron","Oregano","Orienta","Original Surfer","Oswald","Over the Rainbow","Overlock","Overlock SC","Ovo","Oxygen","Oxygen Mono","PT Mono","PT Sans","PT Sans Caption","PT Sans Narrow","PT Serif","PT Serif Caption","Pacifico","Paprika","Parisienne","Passero One","Passion One","Patrick Hand","Patrick Hand SC","Patua One","Paytone One","Peralta","Permanent Marker","Petit Formal Script","Petrona","Philosopher","Piedra","Pinyon Script","Pirata One","Plaster","Play","Playball","Playfair Display","Playfair Display SC","Podkova","Poiret One","Poller One","Poly","Pompiere","Pontano Sans","Port Lligat Sans","Port Lligat Slab","Prata","Preahvihear","Press Start 2P","Princess Sofia","Prociono","Prosto One","Puritan","Purple Purse","Quando","Quantico","Quattrocento","Quattrocento Sans","Questrial","Quicksand","Quintessential","Qwigley","Racing Sans One","Radley","Raleway","Raleway Dots","Rambla","Rammetto One","Ranchers","Rancho","Rationale","Redressed","Reenie Beanie","Revalia","Ribeye","Ribeye Marrow","Righteous","Risque","Roboto","Roboto Condensed","Roboto Slab","Rochester","Rock Salt","Rokkitt","Romanesco","Ropa Sans","Rosario","Rosarivo","Rouge Script","Ruda","Rufina","Ruge Boogie","Ruluko","Rum Raisin","Ruslan Display","Russo One","Ruthie","Rye","Sacramento","Sail","Salsa","Sanchez","Sancreek","Sansita One","Sarina","Satisfy","Scada","Schoolbell","Seaweed Script","Sevillana","Seymour One","Shadows Into Light","Shadows Into Light Two","Shanti","Share","Share Tech","Share Tech Mono","Shojumaru","Short Stack","Siemreap","Sigmar One","Signika","Signika Negative","Simonetta","Sintony","Sirin Stencil","Six Caps","Skranji","Slackey","Smokum","Smythe","Sniglet:800","Snippet","Snowburst One","Sofadi One","Sofia","Sonsie One","Sorts Mill Goudy","Source Code Pro","Source Sans Pro","Special Elite","Spicy Rice","Spinnaker","Spirax","Squada One","Stalemate","Stalinist One","Stardos Stencil","Stint Ultra Condensed","Stint Ultra Expanded","Stoke","Strait","Sue Ellen Francisco","Sunshiney","Supermercado One","Suwannaphum","Swanky and Moo Moo","Syncopate","Tangerine","Taprom","Tauri","Telex","Tenor Sans","Text Me One","The Girl Next Door","Tienne","Tinos","Titan One","Titillium Web","Trade Winds","Trocchi","Trochut","Trykker","Tulpen One","Ubuntu","Ubuntu Condensed","Ubuntu Mono","Ultra","Uncial Antiqua","Underdog","Unica One","UnifrakturCook:700","UnifrakturMaguntia","Unkempt","Unlock","Unna","VT323","Vampiro One","Varela","Varela Round","Vast Shadow","Vibur","Vidaloka","Viga","Voces","Volkhov","Vollkorn","Voltaire","Waiting for the Sunrise","Wallpoet","Walter Turncoat","Warnes","Wellfleet","Wendy One","Wire One","Yanone Kaffeesatz","Yellowtail","Yeseva One","Yesteryear","Zeyada"]}
yit-common/assets/js/yith-panel.js ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+ //image uploader
4
+ var _custom_media = true,
5
+ _orig_send_attachment = wp.media.editor.send.attachment;
6
+
7
+ $('.uploader .button').click(function(e) {
8
+ var send_attachment_bkp = wp.media.editor.send.attachment;
9
+ var button = $(this);
10
+ var id = button.attr('id').replace('_button', '');
11
+ _custom_media = true;
12
+ wp.media.editor.send.attachment = function(props, attachment){
13
+ if ( _custom_media ) {
14
+ $("#"+id).val(attachment.url);
15
+ } else {
16
+ return _orig_send_attachment.apply( this, [props, attachment] );
17
+ };
18
+ }
19
+
20
+ wp.media.editor.open(button);
21
+ return false;
22
+ });
23
+
24
+ $('.add_media').on('click', function(){
25
+ _custom_media = false;
26
+ });
27
+
28
+ //color-picker
29
+ $('.panel-colorpicker').wpColorPicker({
30
+ change: function(event, ui){
31
+ $('#'+event.target.id).parents('.typography_container').find('.font-preview > p').css('color', ui.color.toString());
32
+ }
33
+ });
34
+
35
+ //typography
36
+ $('.typography_container').yit_panel_typography();
37
+
38
+ //datepicker
39
+ $('.panel-datepicker').datepicker({
40
+ showOtherMonths: true,
41
+ selectOtherMonths: true,
42
+ numberOfMonths: 2,
43
+ minDate: 0
44
+ });
45
+ });
46
+
47
+ // typography
48
+ (function( window, $, undefined ) {
49
+
50
+ $.yit_panel_typography = function( options, element ) {
51
+ this.element = $( element );
52
+ this._init( options );
53
+ };
54
+
55
+ $.yit_panel_typography.defaults = {
56
+ elements : {
57
+ size: '.typography_size',
58
+ unit: '.typography_unit',
59
+ family: '.typography_family',
60
+ style: '.typography_style',
61
+ color: '.typography_color',
62
+ preview: '.font-preview p',
63
+ refresh: '.refresh'
64
+ }
65
+ };
66
+
67
+ $.yit_panel_typography.prototype = {
68
+ _init : function( options ) {
69
+ this.options = $.extend( true, {}, $.yit_panel_typography.defaults, options );
70
+
71
+ //init the options string
72
+ if( yit_family_string == '' ) {
73
+ //web fonts
74
+ var web_fonts = $.parseJSON(yit_web_fonts);
75
+ yit_family_string += '<optgroup label="Web Fonts">';
76
+ $.each(web_fonts.items, function(i,v){
77
+ yit_family_string += '<option>' + v + '</option>';
78
+ });
79
+ yit_family_string += '</optgroup>';
80
+
81
+ //google fonts
82
+ var google_fonts = $.parseJSON(yit_google_fonts);
83
+ yit_family_string += '<optgroup label="Google Fonts">';
84
+ $.each(google_fonts.items, function(i,v){
85
+ yit_family_string += '<option>' + v + '</option>';
86
+ });
87
+ yit_family_string += '</optgroup>';
88
+ }
89
+
90
+ this._loadElements();
91
+ this._initEvents();
92
+ },
93
+
94
+ _loadElements : function() {
95
+ var elements = this.options.elements;
96
+ var container = this.element;
97
+
98
+ for( var el in elements) {
99
+ elements[el] = container.find( elements[el] );
100
+ }
101
+ },
102
+
103
+ _initEvents : function() {
104
+ var elements = this.options.elements;
105
+ var self = this;
106
+
107
+ //refresh
108
+ var refresh = elements.refresh;
109
+ refresh.on('click', function(e){
110
+ e.preventDefault();
111
+
112
+ $(this).parent().fadeOut( 'slow' );
113
+
114
+ //Set current value, before trigger change event
115
+
116
+ //Color
117
+ elements.preview.css( 'color', elements.color.val() );
118
+
119
+ //Font size
120
+ var size = elements.size.val();
121
+ var unit = elements.unit.val();
122
+
123
+ elements.preview.css( 'font-size', size + unit );
124
+ elements.preview.css( 'line-height', ( unit == 'em' || unit == 'rem' ? Number( size ) + 0.4 : Number ( size ) + 4 ) + unit );
125
+
126
+ //Font style
127
+ var style = elements.style.val();
128
+
129
+ if( style == 'italic' ) {
130
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'italic' });
131
+ } else if( style == 'bold' ) {
132
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'normal' });
133
+ } else if( style == 'extra-bold' ) {
134
+ elements.preview.css({ 'font-weight' : '800', 'font-style' : 'normal' });
135
+ } else if( style == 'bold-italic' ) {
136
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'italic' });
137
+ } else {
138
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'normal' });
139
+ }
140
+
141
+ //Font Family
142
+ var group = elements.family.find( 'option:selected' ).parent().attr( 'label' );
143
+
144
+ if( group == 'Web fonts' ) {
145
+ //Web font
146
+ elements.preview.css( 'font-family', elements.family.val() );
147
+ } else {
148
+ //Google font
149
+ WebFontConfig = {
150
+ google: {
151
+ families: [ elements.family.find('option:selected' ).text() ] },
152
+ fontactive: function( fontFamily, fontDescription ) {
153
+ elements.preview.css( 'font-family', fontFamily );
154
+ }
155
+ };
156
+
157
+ (function() {
158
+ var wf = document.createElement('script');
159
+ wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
160
+ '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
161
+ wf.type = 'text/javascript';
162
+ wf.async = 'true';
163
+
164
+ var s = document.getElementsByTagName('script')[0];
165
+ s.parentNode.insertBefore(wf, s);
166
+ })();
167
+ }
168
+ });
169
+
170
+ //font size, font unit
171
+ $([elements.size, elements.unit]).each(function(){
172
+ $(this).on('change', function(){
173
+ if( elements.refresh.is( ':visible' ) ) { return; }
174
+
175
+ var size = elements.size.val();
176
+ var unit = elements.unit.val();
177
+
178
+ elements.preview.css({
179
+ 'font-size' : size + unit,
180
+ 'line-height' : ( unit == 'em' || unit == 'rem' ? Number( size ) + 0.4 : Number ( size ) + 4 ) + unit
181
+ }).trigger( 'resize' );
182
+ });
183
+ });
184
+
185
+ //font family
186
+ var family = elements.family;
187
+ family.on('mousedown', function(e){
188
+ var t = $(this);
189
+ if(t.data('instance') == false) {
190
+ var currentElement = {
191
+ 'value' : t.val(),
192
+ 'text' : t.find('option:selected').text()
193
+ };
194
+
195
+ t.html(yit_family_string)
196
+ .find('option')
197
+ .filter(function(){
198
+ return $(this).text() == currentElement.text;
199
+ }).attr('selected', true);
200
+
201
+ t.data('instance', 'true');
202
+ }
203
+ });
204
+ family.on('change', function(){
205
+ if( elements.refresh.is( ':visible' ) ) { return; }
206
+
207
+ var group = $( this ).find( 'option:selected' ).parent().attr( 'label' );
208
+
209
+ if( group == 'Web fonts' ) {
210
+ //Web font
211
+ elements.preview.css( 'font-family', $( this ).val() );
212
+ } else {
213
+ //Google font
214
+ WebFontConfig = {
215
+ google: {
216
+ families: [ $( this ).val() ]
217
+ },
218
+ fontactive: function( fontFamily, fontDescription ) {
219
+ elements.preview.css( 'font-family', fontFamily );
220
+ }
221
+ };
222
+
223
+ (function() {
224
+ var wf = document.createElement('script');
225
+ wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
226
+ '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
227
+ wf.type = 'text/javascript';
228
+ wf.async = 'true';
229
+
230
+ var s = document.getElementsByTagName('script')[0];
231
+ s.parentNode.insertBefore(wf, s);
232
+ })();
233
+ }
234
+
235
+ elements.preview.trigger( 'resize' );
236
+ });
237
+
238
+ elements.style.on('change', function(){
239
+ if( elements.refresh.is( ':visible' ) ) { return; }
240
+
241
+ var style = $( this ).val();
242
+
243
+ if( style == 'italic' ) {
244
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'italic' });
245
+ } else if( style == 'bold' ) {
246
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'normal' });
247
+ } else if( style == 'extra-bold' ) {
248
+ elements.preview.css({ 'font-weight' : '800', 'font-style' : 'normal' });
249
+ } else if( style == 'bold-italic' ) {
250
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'italic' });
251
+ } else {
252
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'normal' });
253
+ }
254
+
255
+ elements.preview.trigger( 'resize' );
256
+ });
257
+
258
+ //preview
259
+ elements.preview.resize(function(){
260
+ var box = $(this).parents('.yit-box');
261
+ $(this).parents('form').height( box.height() );
262
+ });
263
+ }
264
+ };
265
+
266
+ $.fn.yit_panel_typography = function( options ) {
267
+ if ( typeof options === 'string' ) {
268
+ var args = Array.prototype.slice.call( arguments, 1 );
269
+
270
+ this.each(function() {
271
+ var instance = $.data( this, 'yit_panel_typography' );
272
+ if ( !instance ) {
273
+ console.error( "cannot call methods on yit_checkout prior to initialization; " +
274
+ "attempted to call method '" + options + "'" );
275
+ return;
276
+ }
277
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
278
+ console.error( "no such method '" + options + "' for yit_panel_typography instance" );
279
+ return;
280
+ }
281
+ instance[ options ].apply( instance, args );
282
+ });
283
+ }
284
+ else {
285
+ this.each(function() {
286
+ var instance = $.data( this, 'yit_panel_typography' );
287
+ if ( !instance ) {
288
+ $.data( this, 'yit_panel_typography', new $.yit_panel_typography( options, this ) );
289
+ }
290
+ });
291
+ }
292
+ return this;
293
+ };
294
+
295
+
296
+ })( window, jQuery );
yit-common/google_fonts.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Google font management
4
+ */
5
+
6
+ $yith_google_fonts = new Google_Font();
7
+
8
+ class Google_Font {
9
+
10
+ /**
11
+ * @var array The google fonts to include in the page
12
+ */
13
+ public $google_fonts = array();
14
+
15
+ /**
16
+ * Generate the url for the google fonts
17
+ */
18
+ public function google_fonts_url() {
19
+ $base_url = 'http://fonts.googleapis.com/css?family=';
20
+ $fonts = array();
21
+
22
+ if ( empty( $this->google_fonts ) ) return;
23
+
24
+ foreach ( $this->google_fonts as $font => $variants ) {
25
+ $fonts[] = urlencode( $font . ':' . implode( ',', $variants ) );
26
+ }
27
+
28
+ return $base_url . implode( '|', $fonts );
29
+ }
30
+
31
+ /**
32
+ * Add a new google font in queue
33
+ *
34
+ * @param $font The name of google font
35
+ * @param array $variants The variatns for the google font to add
36
+ */
37
+ public function add_google_font( $font, $variants = array() ) {
38
+ if ( ! is_array( $variants ) ) $variants = array( $variants );
39
+
40
+ foreach ( $variants as $variant ) {
41
+ if ( ! isset( $this->google_fonts[$font] ) ) $this->google_fonts[$font] = array( 300, 400 );
42
+ if ( ! in_array( $variant, $this->google_fonts[$font] ) ) $this->google_fonts[$font][] = $variant;
43
+ }
44
+ }
45
+ }
46
+
47
+ if ( ! function_exists( 'yith_add_google_font' ) ) {
48
+ /**
49
+ * Add a new google font in queue
50
+ *
51
+ * @param $font The name of google font
52
+ * @param array $variant The variatns for the google font to add
53
+ */
54
+ function yith_add_google_font( $font, $variant = array() ) {
55
+ global $yith_google_fonts;
56
+ $yith_google_fonts->add_google_font( $font, $variant );
57
+ }
58
+ }
59
+
60
+ if ( ! function_exists( 'yith_google_fonts_url' ) ) {
61
+ /**
62
+ * @return string The url with the google fonts to load
63
+ */
64
+ function yith_google_fonts_url() {
65
+ global $yith_google_fonts;
66
+ return $yith_google_fonts->google_fonts_url();
67
+ }
68
+ }
yit-common/yit-functions.php CHANGED
@@ -88,3 +88,121 @@ if( ! function_exists( 'yit_debug') ) {
88
  return $args;
89
  }
90
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  return $args;
89
  }
90
  }
91
+
92
+
93
+ if( ! function_exists('yit_get_options_from_prefix') ) {
94
+ /**
95
+ * Returns an array of all options that starts with a prefix
96
+ *
97
+ * @param string $prefix
98
+ * @return array
99
+ */
100
+ function yit_get_options_from_prefix( $prefix ) {
101
+ if( !$prefix ) return array();
102
+
103
+ global $wpdb;
104
+
105
+ $sql = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '{$prefix}%'";
106
+ $options = $wpdb->get_col( $sql );
107
+ $return = array();
108
+
109
+ foreach( $options as $option ) {
110
+ $return[$option] = get_option( $option );
111
+ }
112
+
113
+ return yit_debug($return);
114
+ }
115
+ }
116
+
117
+ if( !function_exists('yit_wp_roles') ) {
118
+ /**
119
+ * Returns the roles of the site.
120
+ *
121
+ * @return array
122
+ * @since 1.0.0
123
+ */
124
+ function yit_wp_roles() {
125
+ global $wp_roles;
126
+
127
+ if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles();
128
+
129
+ $roles = array();
130
+ foreach( $wp_roles->roles as $k=>$role ) {
131
+ $roles[$k] = $role['name'];
132
+ }
133
+
134
+ return $roles;
135
+ }
136
+ }
137
+
138
+ if( !function_exists('yit_user_roles') ) {
139
+ /**
140
+ * Returns the roles of the user
141
+ *
142
+ * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
143
+ * @return array()
144
+ * @since 1.0.0
145
+ */
146
+ function yit_user_roles( $user_id = null ) {
147
+ if ( is_numeric( $user_id ) )
148
+ $user = get_userdata( $user_id );
149
+ else
150
+ $user = wp_get_current_user();
151
+
152
+ if ( empty( $user ) )
153
+ return false;
154
+
155
+ return (array) $user->roles;
156
+ }
157
+ }
158
+
159
+
160
+ // ADMIN
161
+ if( !function_exists('yit_typo_option_to_css') ) {
162
+ /**
163
+ * Change the typography option saved in database to attributes for css
164
+ *
165
+ * @param array $option The option as saved in the database
166
+ * @return string
167
+ * @since 1.0.0
168
+ */
169
+ function yit_typo_option_to_css( $option ) {
170
+ $attrs = $variant = array();
171
+
172
+ extract( $option );
173
+ $attrs[] = "color: $color;";
174
+ $attrs[] = "font-size: {$size}{$unit};";
175
+ $attrs[] = "font-family: '{$family}';";
176
+ switch ( $style ) {
177
+ case 'regular':
178
+ $attrs[] = 'font-weight: 400;';
179
+ $attrs[] = 'font-style: normal;';
180
+ $variant = 400;
181
+ break;
182
+ case 'bold':
183
+ $attrs[] = 'font-weight: 700;';
184
+ $attrs[] = 'font-style: normal;';
185
+ $variant = 700;
186
+ break;
187
+ case 'extra-bold':
188
+ $attrs[] = 'font-weight: 800;';
189
+ $attrs[] = 'font-style: normal;';
190
+ $variant = 800;
191
+ break;
192
+ case 'italic':
193
+ $attrs[] = 'font-weight: 400;';
194
+ $attrs[] = 'font-style: italic;';
195
+ $variant = 400;
196
+ break;
197
+ case 'bold-italic':
198
+ $attrs[] = 'font-weight: 700;';
199
+ $attrs[] = 'font-style: italic;';
200
+ $variant = 700;
201
+ break;
202
+ }
203
+
204
+ yith_add_google_font( $family, $variant );
205
+
206
+ return implode( "\n", $attrs ) . "\n";
207
+ }
208
+ }
yit-common/yith-panel.php ADDED
@@ -0,0 +1,504 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Your Inspiration Themes Panel
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @version 0.1.0
7
+ */
8
+
9
+ if( !class_exists('YITH_Panel') ) {
10
+ /*
11
+ * The class manages the theme options for the Plugin
12
+ */
13
+ class YITH_Panel {
14
+
15
+ /**
16
+ * Class version
17
+ *
18
+ * @var string
19
+ */
20
+ public $version = '0.1.0';
21
+
22
+ /**
23
+ * Parameters for add_submenu_page
24
+ *
25
+ * add_submenu_page(
26
+ * 'themes.php', // The file name of a standard WordPress admin page
27
+ * 'Theme Options', // The text to be displayed in the title tags of the page when the menu is selected
28
+ * 'Theme Options', // The text to be used for the menu
29
+ * 'administrator', // The capability (or role) required for this menu to be displayed to the user.
30
+ * 'theme-options', // The slug name to refer to this menu by (should be unique for this menu).
31
+ * 'theme_options_display_page' // The function to be called to output the content for this page.
32
+ * );
33
+ *
34
+ * @access protected
35
+ */
36
+ protected $_submenu = array();
37
+
38
+ /**
39
+ * Initial Options definition:
40
+ * 'tab' => array(
41
+ * 'label',
42
+ * 'sections' => array(
43
+ * 'fields' => array(
44
+ * 'option1',
45
+ * 'option2',
46
+ * ...
47
+ * )
48
+ * )
49
+ * )
50
+ *
51
+ * @var array
52
+ * @access public
53
+ */
54
+ public $options = array();
55
+
56
+ /**
57
+ * Options group name
58
+ *
59
+ * @var string
60
+ * @access public
61
+ */
62
+ public $option_group = 'panel_group';
63
+
64
+ /**
65
+ * Option name
66
+ *
67
+ * @var string
68
+ * @access public
69
+ */
70
+ public $option_name = 'panel_options';
71
+
72
+ /**
73
+ * Banner links
74
+ *
75
+ * @var string
76
+ * @access public
77
+ */
78
+ public $banner_url = 'http://yithemes.com/?ap_id=plugin';
79
+ public $banner_img = '';
80
+
81
+ /**
82
+ * Constructor
83
+ *
84
+ * @param array $submenu Parameters for add_submenu_page
85
+ * @param array $options Array of plugin options
86
+ *
87
+ */
88
+ public function __construct( $submenu, $options, $banner = array(), $option_group = false, $option_name = false ) {
89
+ $this->_submenu = apply_filters('yith_panel_submenu', $submenu);
90
+ $this->options = apply_filters('yith_panel_options', $options);
91
+
92
+ if( !empty($banner) ) {
93
+ $this->banner_url = $banner['url'];
94
+ $this->banner_img = $banner['img'];
95
+ }
96
+
97
+ if( $option_group ) {
98
+ $this->option_group = $option_group;
99
+ }
100
+
101
+ if( $option_name ) {
102
+ $this->option_name = $option_name;
103
+ }
104
+
105
+ //add new menu item
106
+ //register new settings option group
107
+ //include js and css files
108
+ //print browser
109
+ add_action( 'admin_menu', array( $this, 'add_submenu_page') );
110
+ add_action( 'admin_init', array( $this, 'panel_register_setting') );
111
+ add_action( 'admin_enqueue_scripts', array( $this, 'panel_enqueue') );
112
+
113
+ // add the typography javascript vars
114
+ add_action( 'yith_panel_after_panel', array( $this, 'js_typo_vars' ) );
115
+ }
116
+
117
+ /**
118
+ * Create new submenu page
119
+ *
120
+ * @return void
121
+ * @access public
122
+ * @link http://codex.wordpress.org/Function_Reference/add_submenu_page
123
+ */
124
+ public function add_submenu_page() {
125
+ $submenu = $this->_submenu;
126
+ add_submenu_page(
127
+ $submenu[0],
128
+ $submenu[1],
129
+ $submenu[2],
130
+ $submenu[3],
131
+ $submenu[4],
132
+ array( $this, isset($submenu[5]) ? $submenu[5] : 'display_panel_page' )
133
+ );
134
+ }
135
+
136
+ /**
137
+ * Print the Panel page
138
+ *
139
+ * @return void
140
+ * @access public
141
+ */
142
+ public function display_panel_page() {
143
+ // Create a header in the default WordPress 'wrap' container
144
+ $page = $this->_get_tab();
145
+ ?>
146
+ <div id="icon-themes" class="icon32"><br /></div>
147
+ <h2 class="nav-tab-wrapper">
148
+ <?php foreach( $this->options as $k=>$tab ): ?>
149
+ <a class="nav-tab<?php if( $page == $k ): ?> nav-tab-active<?php endif ?>" href="<?php echo add_query_arg('panel_page', $k) ?>"><?php echo $tab['label'] ?></a>
150
+ <?php endforeach ?>
151
+ <?php do_action('yith_panel_after_tabs'); ?>
152
+ </h2>
153
+
154
+ <div class="wrap">
155
+ <?php $this->printBanner() ?>
156
+ <?php do_action('yith_panel_before_panel'); ?>
157
+ <form action="options.php" method="post">
158
+
159
+ <?php do_settings_sections( $this->option_name ); ?>
160
+ <?php settings_fields( $this->option_group ) ?>
161
+
162
+ <p class="submit">
163
+ <input type="hidden" name="panel_page" value="<?php echo $page ?>" />
164
+ <input class="button-primary" type="submit" name="save_options" value="Save Options" />
165
+ </p>
166
+ </form>
167
+ <?php do_action('yith_panel_after_panel'); ?>
168
+ </div>
169
+ <?php
170
+ }
171
+
172
+ /**
173
+ * Add the vars for the typography options
174
+ */
175
+ public function js_typo_vars() {
176
+ global $yith_panel_if_typography;
177
+ if ( ! isset( $yith_panel_if_typography ) || ! $yith_panel_if_typography ) return;
178
+
179
+ $web_fonts = array(
180
+ "Arial",
181
+ "Arial Black",
182
+ "Comic Sans MS",
183
+ "Courier New",
184
+ "Georgia",
185
+ "Impact",
186
+ "Lucida Console",
187
+ "Lucida Sans Unicode",
188
+ "Thaoma",
189
+ "Trebuchet MS",
190
+ "Verdana"
191
+ );
192
+
193
+ // http://niubbys.altervista.org/google_fonts.php
194
+ $google_fonts = file_get_contents( dirname(__FILE__) . '/assets/js/google_fonts.json' );
195
+ ?>
196
+ <script type="text/javascript">
197
+ var yit_google_fonts = '<?php echo $google_fonts ?>',
198
+ yit_web_fonts = '{"items":<?php echo json_encode( $web_fonts ) ?>}',
199
+ yit_family_string = '';
200
+ </script>
201
+ <?php
202
+ }
203
+
204
+ /**
205
+ * Register a new settings option group
206
+ *
207
+ * @return void
208
+ * @access public
209
+ * @link http://codex.wordpress.org/Function_Reference/register_setting
210
+ * @link http://codex.wordpress.org/Function_Reference/add_settings_section
211
+ * @link http://codex.wordpress.org/Function_Reference/add_settings_field
212
+ */
213
+ public function panel_register_setting() {
214
+ $page = $this->_get_tab();
215
+ $tab = isset( $this->options[$page] ) ? $this->options[$page] : array();
216
+
217
+ if( !empty($tab['sections']) ) {
218
+ //add sections and fields
219
+ foreach( $tab['sections'] as $section_name => $section) {
220
+ //add the section
221
+ add_settings_section(
222
+ $section_name,
223
+ $section['title'],
224
+ array( $this, 'panel_section_content'),
225
+ $this->option_name
226
+ );
227
+
228
+ //add the fields
229
+ foreach( $section['fields'] as $option_name => $option ) {
230
+ $option['id'] = $option_name;
231
+ $option['label_for'] = $option_name;
232
+
233
+ //register settings group
234
+ register_setting(
235
+ $this->option_group,
236
+ $option_name,
237
+ array( $this, 'panel_sanitize')
238
+ );
239
+
240
+ add_settings_field(
241
+ $option_name,
242
+ $option['title'],
243
+ array( $this, 'panel_field_content' ),
244
+ $this->option_name,
245
+ $section_name,
246
+ $option
247
+ );
248
+ }
249
+ }
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Display sections content
255
+ *
256
+ * @return void
257
+ * @access public
258
+ */
259
+ public function panel_section_content( $section ) {
260
+ $page = $this->_get_tab();
261
+ if( isset( $this->options[$page]['sections'][ $section['id'] ]['description'] )) {
262
+ echo "<p class='section-description'>" . $this->options[$page]['sections'][ $section['id'] ]['description'] . "</p>";
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Sanitize the option's value
268
+ *
269
+ * @param array $input
270
+ * @return array
271
+ * @access public
272
+ */
273
+ public function panel_sanitize( $input ) {
274
+ return apply_filters('yith_panel_sanitize', $input);
275
+ }
276
+
277
+ /**
278
+ * Get the active tab. If the page isn't provided, the function
279
+ * will return the first tab name
280
+ *
281
+ * @return string
282
+ * @access protected
283
+ */
284
+ public function _get_tab() {
285
+ if( isset($_POST['panel_page']) && $_POST['panel_page'] != '' ) {
286
+ return $_POST['panel_page'];
287
+ } elseif( isset($_GET['panel_page']) && $_GET['panel_page'] != '' ) {
288
+ return $_GET['panel_page'];
289
+ } else {
290
+ $tabs = array_keys( $this->options );
291
+ return $tabs[0];
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Enqueue scripts and styles
297
+ *
298
+ * @return void
299
+ * @access public
300
+ */
301
+ public function panel_enqueue( $hook ) {
302
+ global $pagenow;
303
+
304
+ if( $pagenow == $this->_submenu[0] && isset( $_GET['page'] ) && $_GET['page'] == $this->_submenu[4] ) {
305
+ wp_enqueue_style( 'wp-color-picker' );
306
+ wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css' );
307
+ wp_enqueue_script( 'jquery-ui-datepicker' );
308
+
309
+ wp_enqueue_style( 'yith-panel-css', plugin_dir_url( __FILE__ ) . 'assets/css/yith-panel.css', array('wp-color-picker'), $this->version );
310
+ wp_enqueue_script( 'yith-panel-js', plugin_dir_url( __FILE__ ) . 'assets/js/yith-panel.js', array( 'jquery', 'wp-color-picker' ), $this->version, true );
311
+
312
+ wp_enqueue_media();
313
+
314
+ do_action( 'yith_panel_enqueue' );
315
+ }
316
+ }
317
+
318
+
319
+ /**
320
+ * Display field content
321
+ *
322
+ * @return void
323
+ * @access public
324
+ */
325
+ public function panel_field_content( $field ) {
326
+ $value = get_option( $field['id'], isset($field['std']) ? $field['std'] : '' );
327
+ $id = $field['id'];
328
+ $name = $field['id'];
329
+
330
+ $echo = '';
331
+
332
+ switch( $field['type'] ) {
333
+ case 'text':
334
+ $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' />";
335
+
336
+ if( isset($field['description']) && $field['description'] != '' ) {
337
+ $echo .= "<p class='description'>{$field['description']}</p>";
338
+ }
339
+ break;
340
+
341
+ case 'textarea': $echo = "<textarea name='{$name}' id='{$id}' class='large-text code' rows='10' cols='50'>{$value}</textarea>";
342
+ if( isset($field['description']) && $field['description'] != '' ) {
343
+ $echo .= "<p class='description'>{$field['description']}</p>";
344
+ }
345
+ break;
346
+
347
+ case 'checkbox': $echo = "<input type='checkbox' id='{$id}' name='{$name}' value='1' ". checked($value, true, false) ." />";
348
+ if( isset($field['description']) && $field['description'] != '' ) {
349
+ $echo .= " <label for='{$id}'><span class='description'>{$field['description']}</span></label>";
350
+ }
351
+ break;
352
+
353
+ case 'select': $echo = "<select name='{$name}' id='{$id}'>";
354
+ foreach( $field['options'] as $v=>$label ) {
355
+ $echo .= "<option value='{$v}'". selected($value, $v, false) .">{$label}</option>";
356
+ }
357
+ $echo .= "</select>";
358
+ if( isset($field['description']) && $field['description'] != '' ) {
359
+ $echo .= "<p class='description'>{$field['description']}</p>";
360
+ }
361
+ break;
362
+
363
+ case 'number':
364
+ $mms = '';
365
+ if( isset( $field['min'] ) ) {
366
+ $mms .= " min='{$field['min']}'";
367
+ }
368
+
369
+ if( isset( $field['max'] ) ) {
370
+ $mms .= " max='{$field['max']}'";
371
+ }
372
+
373
+ if( isset( $field['step'] ) ) {
374
+ $mms .= " step='{$field['step']}'";
375
+ }
376
+
377
+ $echo = "<input type='number' id='{$id}' name='{$name}' value='{$value}' class='small-text' {$mms} />";
378
+ if( isset($field['description']) && $field['description'] != '' ) {
379
+ $echo .= "<p class='description'>{$field['description']}</p>";
380
+ }
381
+ break;
382
+
383
+ case 'colorpicker':
384
+ $std = isset( $field['std'] ) ? $field['std'] : '';
385
+
386
+ $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='medium-text code panel-colorpicker' data-default-color='{$std}' />";
387
+ if( isset($field['description']) && $field['description'] != '' ) {
388
+ $echo .= "<p class='description'>{$field['description']}</p>";
389
+ }
390
+ break;
391
+
392
+ case 'datepicker':
393
+ $std = isset( $field['std'] ) ? $field['std'] : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
394
+ $value = ! empty( $value ) ? $value : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
395
+
396
+ $echo = "<input type='text' id='{$id}_date' name='{$name}[date]' value='{$value['date']}' class='medium-text code panel-datepicker' colorpicker='" . __( 'Select a date', 'yit' ) . "' /> - ";
397
+ $echo .= "<input type='text' id='{$id}_hh' name='{$name}[hh]' value='{$value['hh']}' class='small-text code' colorpicker='" . __( 'Hours', 'yit' ) . "' /> : ";
398
+ $echo .= "<input type='text' id='{$id}_mm' name='{$name}[mm]' value='{$value['mm']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' /> : ";
399
+ $echo .= "<input type='text' id='{$id}_ss' name='{$name}[ss]' value='{$value['ss']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' />";
400
+ if( isset($field['description']) && $field['description'] != '' ) {
401
+ $echo .= "<p class='description'>{$field['description']}</p>";
402
+ }
403
+ break;
404
+
405
+ case 'upload':
406
+ $echo = '<div class="uploader">';
407
+ $echo .= " <input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' /> <input type='button' name='' id='{$id}_button' class='button' value='". __('Upload', 'yit') ."'>";
408
+ $echo .= '</div>';
409
+ if( isset($field['description']) && $field['description'] != '' ) {
410
+ $echo .= "<p class='description'>{$field['description']}</p>";
411
+ }
412
+ break;
413
+
414
+ case 'checkboxes':
415
+ $echo = '<div class="checkboxes">';
416
+ foreach ( $field['options'] as $check_value => $check_label ) {
417
+ $echo .= "<label><input type='checkbox' id='{$id}_{$check_value}' name='{$name}[]' value='$check_value' ". checked( in_array( $check_value, $value ), true, false) ." /> {$check_label}</label><br />";
418
+ }
419
+
420
+ $echo .= " <p class='description'>{$field['description']}</p>";
421
+ break;
422
+
423
+ case 'typography': $value = wp_parse_args( $value, $field['std'] ); ?>
424
+ <div class="typography_container typography">
425
+ <div class="option">
426
+ <!-- Size -->
427
+ <div class="spinner_container">
428
+ <input class="typography_size number small-text" type="number" name="<?php echo $name ?>[size]" id="<?php echo $id ?>-size" value="<?php echo $value['size'] ?>" data-min="<?php if(isset( $field['min'] )) echo $field['min'] ?>" data-max="<?php if(isset( $field['max'] )) echo $field['max'] ?>" />
429
+ </div>
430
+
431
+ <!-- Unit -->
432
+ <div class="select-wrapper font-unit">
433
+ <select class="typography_unit" name="<?php echo $name ?>[unit]" id="<?php echo $id ?>-unit">
434
+ <option value="px" <?php selected( $value['unit'], 'px' ) ?>><?php _e( 'px', 'yit' ) ?></option>
435
+ <option value="em" <?php selected( $value['unit'], 'em' ) ?>><?php _e( 'em', 'yit' ) ?></option>
436
+ <option value="pt" <?php selected( $value['unit'], 'pt' ) ?>><?php _e( 'pt', 'yit' ) ?></option>
437
+ <option value="rem" <?php selected( $value['unit'], 'rem' ) ?>><?php _e( 'rem', 'yit' ) ?></option>
438
+ </select>
439
+ </div>
440
+
441
+ <!-- Family -->
442
+ <div class="select-wrapper font-family">
443
+ <select class="typography_family" name="<?php echo $name ?>[family]" id="<?php echo $id ?>-family" data-instance="false">
444
+ <?php if( $value['family'] ): ?>
445
+ <option value="<?php echo stripslashes( $value['family'] ) ?>"><?php echo $value['family'] ?></option>
446
+ <?php else: ?>
447
+ <option value=""><?php _e('Select a font family', 'yit') ?></option>
448
+ <?php endif ?>
449
+ </select>
450
+ </div>
451
+
452
+ <!-- Style -->
453
+ <div class="select-wrapper font-style">
454
+ <select class="typography_style" name="<?php echo $name ?>[style]" id="<?php echo $id ?>-style">
455
+ <option value="regular" <?php selected( $value['style'], 'regular' ) ?>><?php _e( 'Regular', 'yit' ) ?></option>
456
+ <option value="bold" <?php selected( $value['style'], 'bold' ) ?>><?php _e( 'Bold', 'yit' ) ?></option>
457
+ <option value="extra-bold" <?php selected( $value['style'], 'extra-bold' ) ?>><?php _e( 'Extra bold', 'yit' ) ?></option>
458
+ <option value="italic" <?php selected( $value['style'], 'italic' ) ?>><?php _e( 'Italic', 'yit' ) ?></option>
459
+ <option value="bold-italic" <?php selected( $value['style'], 'bold-italic' ) ?>><?php _e( 'Italic bold', 'yit' ) ?></option>
460
+ </select>
461
+ </div>
462
+
463
+ <!-- Color -->
464
+ <input type='text' id='<?php echo $id ?>-color' name='<?php echo $name ?>[color]' value='<?php echo $value['color'] ?>' class='medium-text code panel-colorpicker typography_color' data-default-color='<?php echo $field['std']['color'] ?>' />
465
+
466
+ </div>
467
+ <div class="clear"></div>
468
+ <div class="font-preview">
469
+ <p>The quick brown fox jumps over the lazy dog</p>
470
+ <!-- Refresh -->
471
+ <div class="refresh_container"><button class="refresh"><?php _e( 'Click to preview', 'yit' ) ?></button></div>
472
+ </div>
473
+ </div>
474
+ <?php
475
+ global $yith_panel_if_typography;
476
+ $yith_panel_if_typography = true;
477
+ break;
478
+
479
+ default:
480
+ do_action('yith_panel_field_' . $field['type']);
481
+ break;
482
+ }
483
+
484
+ echo $echo;
485
+ }
486
+
487
+ /**
488
+ * Print the banner
489
+ *
490
+ * @access protected
491
+ * @return void
492
+ */
493
+ public function printBanner() {
494
+ if( !$this->banner_url || !$this->banner_img ) return;
495
+ ?>
496
+ <div class="yith_banner">
497
+ <a href="<?php echo $this->banner_url ?>" target="_blank">
498
+ <img src="<?php echo $this->banner_img ?>" alt="" />
499
+ </a>
500
+ </div>
501
+ <?php
502
+ }
503
+ }
504
+ }