Changeset 2000706
- Timestamp:
- 12/23/2018 07:22:00 PM (7 years ago)
- Location:
- sponsors-carousel/trunk
- Files:
-
- 1 added
- 2 edited
-
js/sponsors-carousel-block.js (added)
-
readme.txt (modified) (2 diffs)
-
sponsors-carousel.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sponsors-carousel/trunk/readme.txt
r1990081 r2000706 13 13 14 14 == Description == 15 16 NEW! Introduced Wordpress 5.0 Gutenberg Editor block! 15 17 16 18 Sponsors Carousel implements the jCarousel as a WordPress plugin. … … 66 68 * 3.07: added link to settings page in plugins list 67 69 * 3.08: WP 5.0 + some css 70 * 4.00: Introduced Gutenberg editor block -
sponsors-carousel/trunk/sponsors-carousel.php
r1990081 r2000706 4 4 * Plugin URI: http://wordpress.org/extend/plugins/sponsors-carousel 5 5 * Description: Sponsors logos on javascript carousel. 6 * Version: 3.086 * Version: 4.00 7 7 * Author: Sergey Panasenko <[email protected]> 8 8 * Text Domain: sponsors-carousel … … 12 12 /* Copyright 2017 Sergey Panasenko (email: [email protected]) 13 13 14 This program is free software; you can redistribute it and/or modify15 it under the terms of the GNU General Public License as published by16 the Free Software Foundation; either version 2 of the License, or17 (at your option) any later version.14 This program is free software; you can redistribute it and/or modify 15 it under the terms of the GNU General Public License as published by 16 the Free Software Foundation; either version 2 of the License, or 17 (at your option) any later version. 18 18 19 This program is distributed in the hope that it will be useful,20 but WITHOUT ANY WARRANTY; without even the implied warranty of21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22 GNU General Public License for more details.19 This program is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 23 23 24 You should have received a copy of the GNU General Public License25 along with this program; if not, write to the Free Software26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 27 */ 28 28 29 define("SPONSORS_CAROUSEL_VERSION", " 3.0.8");29 define("SPONSORS_CAROUSEL_VERSION", "4.00"); 30 30 31 31 include_once("class-sponsors-carousel.php"); … … 33 33 $scwp_plugin_name = __( "Sponsors Carousel", 'sponsors-carousel' ); 34 34 $scwp_plugin_filename = basename( __FILE__ ); //"sponsors-carousel.php"; 35 load_plugin_textdomain( 'sponsors-carousel', NULL, dirname( plugin_basename( __FILE__ ) ) . "/languages" ); 35 36 load_plugin_textdomain( 'sponsors-carousel', NULL, 37 dirname( plugin_basename( __FILE__ ) ) . "/languages" ); 36 38 37 39 add_shortcode( 'sponsors_carousel', function( $arg ) { 38 return sponsors_carousel( isset( $arg['id'] ) ? $arg['id'] : 0 );40 return sponsors_carousel( isset( $arg['id'] ) ? $arg['id'] : 0 ); 39 41 }); 40 42 41 43 add_action( 'wp_enqueue_scripts', function () { 42 wp_enqueue_script( 'jcarousel', plugins_url( '/js/jquery.jcarousel.min.js', __FILE__ ), ['jquery'], SPONSORS_CAROUSEL_VERSION);43 wp_enqueue_script( 'jcarousel-autoscroll', plugins_url( '/js/jquery.jcarousel-autoscroll.min.js', __FILE__ ), ['jquery','jcarousel'], SPONSORS_CAROUSEL_VERSION );44 wp_enqueue_script( 'sponsors-carousel', plugins_url( '/js/sponsors-carousel.js', __FILE__ ), ['jquery','jcarousel','jcarousel-autoscroll'], SPONSORS_CAROUSEL_VERSION );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 ); 45 47 } ); 46 48 47 49 add_action('wp_print_styles', function () { 48 wp_enqueue_style( 'dashicons' );49 wp_enqueue_style( 'sponsors-carousel', plugins_url( '/css/sponsors-carousel.css', __FILE__ ) );50 wp_enqueue_style( 'dashicons' ); 51 wp_enqueue_style( 'sponsors-carousel', plugins_url( '/css/sponsors-carousel.css', __FILE__ ) ); 50 52 } ); 51 53 52 54 add_action('admin_init', function () { 53 wp_register_script( 'sponsors-carousel-admin', plugins_url( '/js/sponsors-carousel-admin.js', __FILE__ ),['jquery', 'jquery-ui-core', 'jquery-ui-sortable'], SPONSORS_CAROUSEL_VERSION );54 wp_register_style( 'sponsors-carousel-admin', plugins_url( '/css/sponsors-carousel-admin.css', __FILE__ ), [], SPONSORS_CAROUSEL_VERSION );55 add_action( 'wp_ajax_sponsors_carousel_change_link', 'scwp_wp_ajax_sponsors_carousel_change_link');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'); 56 58 }); 57 59 58 60 add_action( 'admin_menu', function () { 59 global $scwp_plugin_name; 60 $page = add_menu_page( $scwp_plugin_name, $scwp_plugin_name, 'manage_options', 'sponsors_carousel', 'scwp_options_page', 'dashicons-format-gallery', 55 ); 61 add_action('admin_print_scripts-' . $page, 'scwp_admin_enqueue_scripts'); 62 add_filter( 'plugin_action_links', 'scwp_add_quick_settings_link', 10, 2 ); 61 global $scwp_plugin_name; 62 $icon = 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg"><path fill="black" d="m160 0a160 160 0 0 0 -160 160 160 160 0 0 0 160 160 160 160 0 0 0 160 -160 160 160 0 0 0 -160 -160zm-50.7 110.6c9.3 0 18.7 2.2 26.8 6.9l-6.3 16.5c-5.9-3.6-12.7-5.5-19.5-5.7-6.1-.9-14.85 2.6-12.62 10.2 3.62 8.5 14.42 9.2 21.82 13 10.3 3.6 19.6 12.4 19.8 23.9 1.7 11.4-5 23.3-16.1 26.9-15.7 5.1-33.95 3.5-48.45-4.6 1.99-5.6 3.98-11.1 5.98-16.7 8.69 5.1 18.85 7.5 28.77 6.2 6.4.2 12-6.4 8.7-12.6-6.6-9.4-19.73-9.4-28.86-15.4-9.7-5.1-14.33-16.8-11.85-27.3 2.27-13.9 16.95-21.5 29.91-21.2.7 0 1.3-.1 1.9-.1zm106.9.1c10.1-.1 20.6 1.9 29.3 7.4-2 5.6-4 11.2-6 16.7-6-3.8-13.1-5.8-20.2-6.1-11.1-1.1-22.2 6.4-24.5 17.5-3 12.6-2.4 29.2 9.3 37.4 11.3 6.4 25.8 3.8 36.8-2.2 1.8 5.6 3.6 11.1 5.4 16.6-5.3 3.5-11.7 5.3-17.9 6.2-16.9 3-37.1-.3-47.2-15.6-9.7-14.7-10.6-34.2-5-50.7 5.9-16.3 22.7-27.4 40-27.2zm-173.7 30.6c8.03 0 14.59 6.6 14.59 14.6s-6.56 14.6-14.59 14.6c-8.04 0-14.6-6.6-14.6-14.6s6.56-14.6 14.6-14.6zm230.4 2.7c8 0 14.5 6.6 14.5 14.6 0 8.1-6.5 14.6-14.5 14.6-8.1 0-14.6-6.5-14.6-14.6 0-8 6.5-14.6 14.6-14.6zm-230.4 1.3c-5.88 0-10.6 4.7-10.6 10.6s4.72 10.6 10.6 10.6c5.87 0 10.59-4.7 10.59-10.6s-4.72-10.6-10.59-10.6zm3.42 1.5a2 2 0 0 1 1.43 3.4l-5.63 5.8 5.48 5.6a2 2 0 0 1 -2.54 3l-.23-.1a2 2 0 0 1 -.64 -.7l-6.3-6.4a2 2 0 0 1 0 -2.8l7-7.2a2 2 0 0 1 1.43 -.6zm227 1.2c-5.9 0-10.6 4.7-10.6 10.6s4.7 10.6 10.6 10.6c5.8 0 10.5-4.7 10.5-10.6s-4.7-10.6-10.5-10.6zm-4.4 1.5a2 2 0 0 1 1.4 .7l7 7.1a2 2 0 0 1 0 2.8l-6.3 6.4a2 2 0 0 1 -.6 .7l-.3.2a2 2 0 0 1 -2.5 -3.1l5.5-5.6-5.7-5.7a2 2 0 0 1 1.5 -3.5z"/></svg>'); 63 $page = add_menu_page( $scwp_plugin_name, $scwp_plugin_name, 'manage_options', 'sponsors_carousel', 'scwp_options_page', $icon, 55 ); 64 add_action('admin_print_scripts-' . $page, 'scwp_admin_enqueue_scripts'); 65 add_filter( 'plugin_action_links', 'scwp_add_quick_settings_link', 10, 2 ); 63 66 } ); 64 67 65 68 function scwp_admin_enqueue_scripts() { 66 wp_enqueue_media();67 wp_enqueue_script( 'jquery-ui-core' );68 wp_enqueue_script( 'jquery-ui-sortable' );69 wp_enqueue_script( 'sponsors-carousel-admin' );70 wp_enqueue_style( 'sponsors-carousel-admin' );69 wp_enqueue_media(); 70 wp_enqueue_script( 'jquery-ui-core' ); 71 wp_enqueue_script( 'jquery-ui-sortable' ); 72 wp_enqueue_script( 'sponsors-carousel-admin' ); 73 wp_enqueue_style( 'sponsors-carousel-admin' ); 71 74 } 72 75 73 76 function scwp_add_quick_settings_link($links, $file) { 74 if ($file == plugin_basename(__FILE__)) {75 $link = admin_url('admin.php?page=sponsors_carousel');76 $dashboard_link = "<a href=\"{$link}\">" . __( 'Settings', 'sponsors-carousel' ) . "</a>";77 array_unshift($links, $dashboard_link);78 }79 return $links;77 if ($file == plugin_basename(__FILE__)) { 78 $link = admin_url('admin.php?page=sponsors_carousel'); 79 $dashboard_link = "<a href=\"{$link}\">" . __( 'Settings', 'sponsors-carousel' ) . "</a>"; 80 array_unshift($links, $dashboard_link); 81 } 82 return $links; 80 83 } 81 84 82 85 function scwp_wp_ajax_sponsors_carousel_change_link () { 83 if ( is_admin() ) {84 $post = array(85 'ID' => intval($_POST['image_id']),86 'post_excerpt' => $_POST['link'],87 );88 wp_update_post( $post );89 echo 'Saved';90 }91 wp_die();86 if ( is_admin() ) { 87 $post = array( 88 'ID' => intval($_POST['image_id']), 89 'post_excerpt' => $_POST['link'], 90 ); 91 wp_update_post( $post ); 92 echo 'Saved'; 93 } 94 wp_die(); 92 95 } 93 96 … … 95 98 function scwp_options_page() { 96 99 97 if ( isset( $_POST['save'] ) ) { // Update options98 $sponsors_carousel = new SponsorsCarousel();99 if ( $sponsors_carousel->update( $_POST ) ) {100 echo "<div class='updated fade'><p><strong>" . __( 'Options updated', 'sponsors-carousel' ) . "</strong></p></div>";101 }102 }100 if ( isset( $_POST['save'] ) ) { // Update options 101 $sponsors_carousel = new SponsorsCarousel(); 102 if ( $sponsors_carousel->update( $_POST ) ) { 103 echo "<div class='updated fade'><p><strong>" . __( 'Options updated', 'sponsors-carousel' ) . "</strong></p></div>"; 104 } 105 } 103 106 104 if ( isset( $_GET['delete'] ) && isset( $_GET['id'] ) && intval( $_GET['id'] ) == intval( $_GET['delete'] ) ) { // Delete carousel105 echo SponsorsCarousel::delete( intval( $_GET['delete'] ) );106 die();107 }107 if ( isset( $_GET['delete'] ) && isset( $_GET['id'] ) && intval( $_GET['id'] ) == intval( $_GET['delete'] ) ) { // Delete carousel 108 echo SponsorsCarousel::delete( intval( $_GET['delete'] ) ); 109 die(); 110 } 108 111 109 global $scwp_plugin_name;110 echo '<h2>' . sprintf( __( '%s Settings', 'sponsors-carousel' ), $scwp_plugin_name ) . '</h2>';111 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;112 echo SponsorsCarousel::show_buttons( $id );113 $option = get_option( 'sponsors-carousel-' . $id );114 if ( false == $option ) {115 $sponsors_carousel = new SponsorsCarousel( $id );116 }117 else $sponsors_carousel = unserialize( $option );118 echo $sponsors_carousel->get_form();112 global $scwp_plugin_name; 113 echo '<h2>' . sprintf( __( '%s Settings', 'sponsors-carousel' ), $scwp_plugin_name ) . '</h2>'; 114 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 115 echo SponsorsCarousel::show_buttons( $id ); 116 $option = get_option( 'sponsors-carousel-' . $id ); 117 if ( false == $option ) { 118 $sponsors_carousel = new SponsorsCarousel( $id ); 119 } 120 else $sponsors_carousel = unserialize( $option ); 121 echo $sponsors_carousel->get_form(); 119 122 } 120 123 121 124 function sponsors_carousel( $id = 0 ) { 122 $id = intval( $id );123 $option = get_option( 'sponsors-carousel-' . $id );124 if ( false == $option ) {125 return false;126 }127 $sponsors_carousel = unserialize( $option );128 return $sponsors_carousel->show();125 $id = intval( $id ); 126 $option = get_option( 'sponsors-carousel-' . $id ); 127 if ( false == $option ) { 128 return false; 129 } 130 $sponsors_carousel = unserialize( $option ); 131 return $sponsors_carousel->show(); 129 132 } 130 133 134 add_action( 'init', function () { 135 136 if ( function_exists( 'register_block_type' )) { 137 $list = get_option( 'sponsors-carousels', '0' ); 138 $ids = explode( ',', $list ); 139 $list = array( array( 'value' => 0, 'label' => __( 'main', 'sponsors-carousel' ))); 140 foreach ( $ids as $id ) { 141 if ( $id > 0 ) { 142 $list[] = array( 'value' => $id, 'label' => $id ); 143 } 144 } 145 146 wp_register_script( 147 'sponsors-carousel-block', 148 plugins_url( 'js/sponsors-carousel-block.js', __FILE__ ), 149 array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ) 150 ); 151 152 register_block_type( 'sponsors-carousel/block', array( 153 'attributes' => array( 154 'id' => array( 155 'type' => 'number', 156 'default' => 0, 157 ), 158 'list' => array( 159 'type' => 'array', 160 'default' => $list, 161 ), 162 'label' => array( 163 'type' => 'string', 164 'default' => __( 'ID', 'sponsors-carousel' ), 165 ), 166 ), 167 'editor_script' => 'sponsors-carousel-block', 168 'render_callback' => 'sponsors_carousel_block_render', 169 ) ); 170 } 171 172 }); 173 174 function sponsors_carousel_block_render( $attributes ) { 175 wp_enqueue_style( 'sponsors-carousel', plugins_url( '/css/sponsors-carousel.css', __FILE__ ) ); 176 $sc = sponsors_carousel( isset( $attributes['id'] ) ? $attributes['id'] : 0 ); 177 return empty( $sc ) ? ( '<p>' . __( 'Please add images on <b>Sponsors carousel</b> plugin page', 'sponsors-carousel' ) . '</p>' ) : $sc; 178 }
Note: See TracChangeset
for help on using the changeset viewer.