Changeset 2028426
- Timestamp:
- 02/11/2019 11:28:20 AM (7 years ago)
- Location:
- sponsors-carousel/trunk
- Files:
-
- 3 edited
-
class-sponsors-carousel.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
sponsors-carousel.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sponsors-carousel/trunk/class-sponsors-carousel.php
r2027712 r2028426 61 61 } 62 62 } 63 }64 65 public function empty() {66 return empty($this->images);67 63 } 68 64 -
sponsors-carousel/trunk/readme.txt
r2027712 r2028426 71 71 * 4.00: Introduced Gutenberg editor block 72 72 * 4.01: Added WP image size chooser to set scale/crop images and carousel copy button. 73 * 4.02: fixed function name conflict, thanks @merchtemeaglesadmin -
sponsors-carousel/trunk/sponsors-carousel.php
r2027713 r2028426 4 4 * Plugin URI: http://wordpress.org/extend/plugins/sponsors-carousel 5 5 * Description: Sponsors logos on javascript carousel. 6 * Version: 4.0 16 * Version: 4.02 7 7 * Author: Sergey Panasenko <[email protected]> 8 8 * Text Domain: sponsors-carousel … … 42 42 43 43 add_action( 'wp_enqueue_scripts', function () { 44 wp_enqueue_script( 'jcarousel', plugins_url( '/js/jquery.jcarousel.min.js', __FILE__ ), ['jquery'], SPONSORS_CAROUSEL_VERSION); 45 wp_enqueue_script( 'jcarousel-autoscroll', plugins_url( '/js/jquery.jcarousel-autoscroll.min.js', __FILE__ ), ['jquery','jcarousel'], SPONSORS_CAROUSEL_VERSION ); 46 wp_enqueue_script( 'sponsors-carousel', plugins_url( '/js/sponsors-carousel.js', __FILE__ ), ['jquery','jcarousel','jcarousel-autoscroll'], SPONSORS_CAROUSEL_VERSION ); 44 wp_enqueue_script( 'jcarousel', 45 plugins_url( '/js/jquery.jcarousel.min.js', __FILE__ ), 46 ['jquery'], SPONSORS_CAROUSEL_VERSION); 47 wp_enqueue_script( 'jcarousel-autoscroll', 48 plugins_url( '/js/jquery.jcarousel-autoscroll.min.js', __FILE__ ), 49 ['jquery','jcarousel'], SPONSORS_CAROUSEL_VERSION ); 50 wp_enqueue_script( 'sponsors-carousel', 51 plugins_url( '/js/sponsors-carousel.js', __FILE__ ), 52 ['jquery','jcarousel','jcarousel-autoscroll'], 53 SPONSORS_CAROUSEL_VERSION ); 47 54 } ); 48 55 49 56 add_action('wp_print_styles', function () { 50 57 wp_enqueue_style( 'dashicons' ); 51 wp_enqueue_style( 'sponsors-carousel', plugins_url( '/css/sponsors-carousel.css', __FILE__ ) ); 58 wp_enqueue_style( 'sponsors-carousel', 59 plugins_url( '/css/sponsors-carousel.css', __FILE__ ) ); 52 60 } ); 53 61 54 62 add_action('admin_init', function () { 55 wp_register_script( 'sponsors-carousel-admin', plugins_url( '/js/sponsors-carousel-admin.js', __FILE__ ),['jquery', 'jquery-ui-core', 'jquery-ui-sortable'], SPONSORS_CAROUSEL_VERSION ); 56 wp_register_style( 'sponsors-carousel-admin', plugins_url( '/css/sponsors-carousel-admin.css', __FILE__ ), [], SPONSORS_CAROUSEL_VERSION ); 57 add_action( 'wp_ajax_sponsors_carousel_change_link', 'scwp_wp_ajax_sponsors_carousel_change_link'); 63 wp_register_script( 'sponsors-carousel-admin', 64 plugins_url( '/js/sponsors-carousel-admin.js', __FILE__ ), 65 ['jquery', 'jquery-ui-core', 'jquery-ui-sortable'], 66 SPONSORS_CAROUSEL_VERSION ); 67 wp_register_style( 'sponsors-carousel-admin', 68 plugins_url( '/css/sponsors-carousel-admin.css', __FILE__ ), 69 [], SPONSORS_CAROUSEL_VERSION ); 70 add_action( 'wp_ajax_sponsors_carousel_change_link', 71 'scwp_wp_ajax_sponsors_carousel_change_link'); 58 72 }); 59 73 … … 77 91 if ($file == plugin_basename(__FILE__)) { 78 92 $link = admin_url('admin.php?page=sponsors_carousel'); 79 $dashboard_link = "<a href=\"{$link}\">" . __( 'Settings', 'sponsors-carousel' ) . "</a>"; 93 $dashboard_link = "<a href=\"{$link}\">"; 94 $dashboard_link .= __( 'Settings', 'sponsors-carousel' ) . "</a>"; 80 95 array_unshift($links, $dashboard_link); 81 96 } … … 98 113 function scwp_options_page() { 99 114 100 if ( isset( $_POST['save'] ) ) { // Update options 115 // Update options 116 if ( isset( $_POST['save'] ) ) { 101 117 $sponsors_carousel = new SponsorsCarousel(); 102 118 if ( $sponsors_carousel->update( $_POST ) ) { 103 echo "<div class='updated fade'><p><strong>" . __( 'Options updated', 'sponsors-carousel' ) . "</strong></p></div>"; 119 echo "<div class='updated fade'><p><strong>"; 120 echo __( 'Options updated', 'sponsors-carousel' ); 121 echo "</strong></p></div>"; 104 122 } 105 123 } 106 124 107 if ( isset( $_GET['copy'] ) ) { // Update options 125 // Copy carousel 126 if ( isset( $_GET['copy'] ) ) { 108 127 $sponsors_carousel = new SponsorsCarousel($_GET['id']); 109 128 echo $sponsors_carousel->copy($_GET['copy']); 110 129 } 111 130 112 if ( isset( $_GET['delete'] ) && isset( $_GET['id'] ) && intval( $_GET['id'] ) == intval( $_GET['delete'] ) ) { // Delete carousel 131 // Delete carousel 132 if ( isset( $_GET['delete'] ) && isset( $_GET['id'] ) && 133 intval( $_GET['id'] ) == intval( $_GET['delete'] ) ) { 113 134 echo SponsorsCarousel::delete( intval( $_GET['delete'] ) ); 114 135 die(); 115 136 } 116 137 138 // Show admin page 117 139 global $scwp_plugin_name; 118 echo '<h2>' . sprintf( __( '%s Settings', 'sponsors-carousel' ), $scwp_plugin_name ) . '</h2>'; 140 echo '<h2>' . sprintf( __( '%s Settings', 'sponsors-carousel' ), 141 $scwp_plugin_name ) . '</h2>'; 119 142 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 120 143 $sponsors_carousel = new SponsorsCarousel( $id ); … … 132 155 $list = get_option( 'sponsors-carousels', '0' ); 133 156 $ids = explode( ',', $list ); 134 $list = array( array( 'value' => 0, 'label' => __( 'main', 'sponsors-carousel' ))); 157 $list = array( array( 'value' => 0, 158 'label' => __( 'main', 'sponsors-carousel' ))); 135 159 foreach ( $ids as $id ) { 136 160 if ( $id > 0 ) { … … 144 168 array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ) 145 169 ); 146 wp_enqueue_style( 'sponsors-carousel', plugins_url( '/css/sponsors-carousel.css', __FILE__ ) ); 170 wp_enqueue_style( 'sponsors-carousel', 171 plugins_url( '/css/sponsors-carousel.css', __FILE__ ) ); 147 172 148 173 register_block_type( 'sponsors-carousel/block', array( … … 170 195 function sponsors_carousel_block_render( $attributes ) { 171 196 $sc = sponsors_carousel( isset( $attributes['id'] ) ? $attributes['id'] : 0 ); 172 return empty( $sc ) ? ( '<p>' . __( 'Please add images on <b>Sponsors carousel</b> plugin page', 'sponsors-carousel' ) . '</p>' ) : $sc; 173 } 197 $message = __( 'Please add images on <b>Sponsors carousel</b> plugin page', 198 'sponsors-carousel' ); 199 return empty( $sc ) ? ( '<p>' . $message . '</p>' ) : $sc; 200 }
Note: See TracChangeset
for help on using the changeset viewer.