Changeset 1454781
- Timestamp:
- 07/14/2016 02:56:33 PM (10 years ago)
- Location:
- wp-magnific-popup/trunk
- Files:
-
- 1 deleted
- 2 edited
-
assets (deleted)
-
js/wpmp.js (modified) (5 diffs)
-
wp_magnific_popup.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-magnific-popup/trunk/js/wpmp.js
r1454500 r1454781 2 2 if (typeof wpmp_options !== 'undefined') 3 3 { 4 if (typeof wpmp_options.image_class !== 'undefined') 5 { 4 6 5 console.log(wpmp_options); 7 if ( wpmp_options.image_class) {8 jQuery('.' + wpmp_options.image _class).magnificPopup({6 if (typeof wpmp_options.image !== 'undefined' && wpmp_options.image.class) { 7 jQuery('.' + wpmp_options.image.class).magnificPopup({ 9 8 type: 'image', 10 9 closeOnContentClick: true, 11 10 image: { 12 verticalFit: wpmp_options.image_vertical_fit11 verticalFit: typeof wpmp_options.image.vertical_fit !== 'undefined' && wpmp_options.image.vertical_fit 13 12 }, 14 13 zoom: { 15 enabled: wpmp_options.image_zoom_enabled,14 enabled: typeof wpmp_options.image.zoom_enabled !== 'undefined' && wpmp_options.image.zoom_enabled, 16 15 duration: 300 17 16 } … … 19 18 } 20 19 21 if ( wpmp_options.gallery_class) {22 jQuery('.' + wpmp_options.gallery _class).magnificPopup({20 if (typeof wpmp_options.gallery !== 'undefined' && wpmp_options.gallery.class) { 21 jQuery('.' + wpmp_options.gallery.class).magnificPopup({ 23 22 delegate: 'a', 24 23 type: 'image', 25 24 tLoading: wpmp_options.image_loading_text, 26 //mainClass: 'mfp-img-mobile',27 25 gallery: { 28 26 enabled: true, … … 39 37 } 40 38 41 if ( wpmp_options.iframe_class) {42 jQuery('.' + wpmp_options.iframe _class).magnificPopup({39 if (typeof wpmp_options.iframe !== 'undefined' && wpmp_options.iframe.class) { 40 jQuery('.' + wpmp_options.iframe.class).magnificPopup({ 43 41 type: 'iframe', 44 42 disableOn: 700, … … 49 47 } 50 48 51 if ( wpmp_options.div_class) {52 jQuery('.' + wpmp_options.div _class).magnificPopup({49 if (typeof wpmp_options.div !== 'undefined' && wpmp_options.div.class) { 50 jQuery('.' + wpmp_options.div.class).magnificPopup({ 53 51 type: 'inline', 54 52 closeBtnInside: true, … … 57 55 } 58 56 } 59 }60 57 }); -
wp-magnific-popup/trunk/wp_magnific_popup.php
r1454500 r1454781 18 18 add_action( 'admin_init', array($this, 'register_settings') ); 19 19 add_action( 'plugins_loaded', array($this, 'load_textdomain') ); 20 add_filter( 'plugin_action_links', array($this, 'plugin_action_links'), 10, 2 ); 21 add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); 22 } 23 24 function admin_scripts() 25 { 26 wp_enqueue_script('jquery-ui-core'); 27 wp_enqueue_script('jquery-ui-tabs'); 28 29 wp_enqueue_script('wpmp-admin', plugins_url('js/admin.js', __FILE__), array('jquery', 'jquery-ui-tabs')); 30 } 31 32 function plugin_action_links($links, $file) 33 { 34 if( false === strpos( $file, basename(__FILE__) ) ) 35 return $links; 36 37 $settings_link = '<a href="options-general.php?page=wp-magnific-popup">' . esc_html__( 'Settings', 'wp-magnific-popup' ) . '</a>'; 38 array_unshift( $links, $settings_link ); 39 40 return $links; 20 41 } 21 42 … … 34 55 function wp_head() 35 56 { 57 36 58 ?> 37 59 <script type="text/javascript"> 38 60 var wpmp_options = { 39 image_class: '<?=get_option('wpmp_image_class')?>', 40 gallery_class: '<?=get_option('wpmp_gallery_class')?>', 61 image: <?=json_encode(get_option('wpmp_image_settings'))?>, 62 gallery: <?=json_encode(get_option('wpmp_gallery_settings'))?>, 63 iframe: <?=json_encode(get_option('wpmp_iframe_settings'))?>, 64 div: <?=json_encode(get_option('wpmp_div_settings'))?>, 41 65 image_loading_text: '<?=__('Loading image #%curr%...', 'wp-magnific-popup')?>', 42 image_error_text: '<?=__('<a href="%url%">The image #%curr%</a> could not be loaded.', 'wp-magnific-popup')?>', 43 image_vertical_fit: <?= get_option('wpmp_image_vertical_fit') == 1 ? 'true' : 'false' ?>, 44 image_zoom_enabled: <?= get_option('wpmp_image_zoom_enabled') == 1 ? 'true' : 'false' ?>, 45 iframe_class: '<?=get_option('wpmp_iframe_class')?>', 46 div_class: '<?=get_option('wpmp_div_class')?>', 66 image_error_text: '<?=__('<a href="%url%">The image #%curr%</a> could not be loaded.', 'wp-magnific-popup')?>' 47 67 }; 48 68 </script> … … 59 79 { 60 80 ?> 81 61 82 <div class="wrap"> 62 83 <h2><?php _e('WP Magnific Popup Settings', 'wp-magnific-popup') ?></h2> 63 84 <form method="post" action="options.php"> 64 85 <?php settings_fields( 'wp-magnific-popup-settings-group' ); ?> 65 <table class="form-table ps-form-table"> 66 <tr> 67 <th colspan="2"><h3><?php _e('Images', 'wp-magnific-popup') ?></h3></th> 68 </tr> 69 <tr> 70 <th><?php _e('CSS class for images', 'wp-magnific-popup') ?>:</th> 71 <td><input type="text" name="wpmp_image_class" value="<?=get_option('wpmp_image_class')?>" /></td> 72 </tr> 73 <tr> 74 <th><?php _e('Vertical Fit', 'wp-magnific-popup') ?>:</th> 75 <td><input type="checkbox" name="wpmp_image_vertical_fit" value="1" <?php if (get_option('wpmp_image_vertical_fit') == 1) echo 'checked="checked"';?> /></td> 76 </tr> 77 <tr> 78 <th><?php _e('Enable Zoom Animation', 'wp-magnific-popup') ?>:</th> 79 <td><input type="checkbox" name="wpmp_image_zoom_enabled" value="1" <?php if (get_option('wpmp_image_zoom_enabled') == 1) echo 'checked="checked"';?> /></td> 80 </tr> 81 <tr> 82 <th colspan="2"><h3><?php _e('Galleries', 'wp-magnific-popup') ?></h3></th> 83 </tr> 84 <tr> 85 <th><?php _e('CSS class for galleries', 'wp-magnific-popup') ?>:</th> 86 <td><input type="text" name="wpmp_gallery_class" value="<?=get_option('wpmp_gallery_class')?>" /></td> 87 </tr> 88 <tr> 89 <th colspan="2"><h3><?php _e('Iframes', 'wp-magnific-popup') ?></h3></th> 90 </tr> 91 <tr> 92 <th><?php _e('CSS class for iframes', 'wp-magnific-popup') ?>:</th> 93 <td><input type="text" name="wpmp_iframe_class" value="<?=get_option('wpmp_iframe_class')?>" /></td> 94 </tr> 95 <tr> 96 <th colspan="2"><h3><?php _e('Dialogs', 'wp-magnific-popup')?></h3></th> 97 </tr> 98 <tr> 99 <th><?php _e('CSS class for dialogs', 'wp-magnific-popup') ?>:</th> 100 <td><input type="text" name="wpmp_div_class" value="<?=get_option('wpmp_div_class')?>" /></td> 101 </tr> 102 </table> 86 <div id="wpmp_tabs"> 87 <ul> 88 <li><a href="#wpmp_images"><?php _e('Images', 'wp-magnific-popup') ?></a></li> 89 <li><a href="#wpmp_galleries"><?php _e('Galleries', 'wp-magnific-popup') ?></a></li> 90 <li><a href="#wpmp_iframe"><?php _e('Iframes', 'wp-magnific-popup') ?></a></li> 91 <li><a href="#wpmp_dialog"><?php _e('Dialogs', 'wp-magnific-popup')?></a></li> 92 </ul> 93 <div id="wpmp_images"> 94 <table class="form-table ps-form-table"> 95 <tr> 96 <th><?php _e('CSS class for images', 'wp-magnific-popup') ?>:</th> 97 <td><input type="text" name="wpmp_image_settings[class]" value="<?=$this->get_wpmp_option('image', 'class')?>" /></td> 98 </tr> 99 <tr> 100 <th><?php _e('Vertical Fit', 'wp-magnific-popup') ?>:</th> 101 <td><input type="checkbox" name="wpmp_image_settings[vertical_fit]" value="1" <?php if ($this->get_wpmp_option('image', 'vertical_fit') == 1) echo 'checked="checked"';?> /></td> 102 </tr> 103 <tr> 104 <th><?php _e('Enable Zoom Animation', 'wp-magnific-popup') ?>:</th> 105 <td><input type="checkbox" name="wpmp_image_settings[zoom_enabled]" value="1" <?php if ($this->get_wpmp_option('image', 'zoom_enabled') == 1) echo 'checked="checked"';?> /></td> 106 </tr> 107 </table> 108 </div> 109 <div id="wpmp_galleries"> 110 <table class="form-table ps-form-table"> 111 <tr> 112 <th><?php _e('CSS class for galleries', 'wp-magnific-popup') ?>:</th> 113 <td><input type="text" name="wpmp_gallery_settings[class]" value="<?=$this->get_wpmp_option('gallery', 'class')?>" /></td> 114 </tr> 115 </table> 116 </div> 117 <div id="wpmp_iframe"> 118 <table class="form-table ps-form-table"> 119 <tr> 120 <th><?php _e('CSS class for iframes', 'wp-magnific-popup') ?>:</th> 121 <td><input type="text" name="wpmp_iframe_settings[class]" value="<?=$this->get_wpmp_option('iframe', 'class')?>" /></td> 122 </tr> 123 </table> 124 </div> 125 <div id="wpmp_dialog"> 126 <table class="form-table ps-form-table"> 127 <tr> 128 <th><?php _e('CSS class for dialogs', 'wp-magnific-popup') ?>:</th> 129 <td><input type="text" name="wpmp_div_settings[class]" value="<?=$this->get_wpmp_option('div', 'class')?>" /></td> 130 </tr> 131 </table> 132 </div> 133 </div> 134 103 135 <p class="submit"> 104 136 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> … … 109 141 } 110 142 143 function get_wpmp_option($section, $option) 144 { 145 $arr = get_option('wpmp_'.$section.'_settings'); 146 147 if ($arr) 148 { 149 if (isset($arr[$option])) 150 return $arr[$option]; 151 } 152 return ''; 153 } 154 111 155 function register_settings() 112 156 { 113 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_gallery_class' ); 114 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_image_class' ); 115 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_image_vertical_fit' ); 116 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_image_zoom_enabled' ); 117 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_iframe_class' ); 118 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_div_class' ); 157 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_image_settings' ); 158 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_gallery_settings' ); 159 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_iframe_settings' ); 160 register_setting( 'wp-magnific-popup-settings-group', 'wpmp_div_settings' ); 119 161 } 120 162 … … 126 168 function install_wp_magnific_popup() 127 169 { 128 if (!get_option('wpmp_image_class')) 129 update_option('wpmp_image_class', 'mpopup'); 130 if (!get_option('wpmp_iframe_class')) 131 update_option('wpmp_iframe_class', 'mpopup_iframe'); 132 if (!get_option('wpmp_div_class')) 133 update_option('wpmp_div_class', 'mpopup_div'); 134 if (!get_option('wpmp_gallery_class')) 135 update_option('wpmp_gallery_class', 'popup-gallery'); 170 if (!get_option('wpmp_image_settings')) 171 update_option('wpmp_image_settings', array( 172 'class' => 'mpopup', 173 'vertical_fit' => 1, 174 'zoom_enabled' => 0 175 )); 176 177 if (!get_option('wpmp_gallery_settings')) 178 update_option('wpmp_gallery_settings', array( 179 'class' => 'popup-gallery' 180 )); 181 182 if (!get_option('wpmp_iframe_settings')) 183 update_option('wpmp_iframe_settings', array( 184 'class' => 'mpopup_iframe' 185 )); 186 187 if (!get_option('wpmp_div_settings')) 188 update_option('wpmp_div_settings', array( 189 'class' => 'mpopup_div' 190 )); 136 191 }
Note: See TracChangeset
for help on using the changeset viewer.