Changeset 2071135
- Timestamp:
- 04/19/2019 08:10:47 AM (7 years ago)
- Location:
- dokiv-sharing/trunk
- Files:
-
- 8 added
- 3 edited
-
assets/css (added)
-
assets/css/jquery.fancybox.min.css (added)
-
assets/js/dokiv-button-box.png (added)
-
assets/js/dokiv_sharing.js (modified) (3 diffs)
-
assets/js/dokiv_sharing_lightbox.js (added)
-
assets/js/jquery.fancybox.min.js (added)
-
dokiv_sharing.php (modified) (3 diffs)
-
libs (added)
-
libs/custom_walker_edit.php (added)
-
libs/menu_item_custom_fields.php (added)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dokiv-sharing/trunk/assets/js/dokiv_sharing.js
r2064958 r2071135 2 2 tinymce.PluginManager.add('dokiv_share_button', function(editor, url) { 3 3 editor.addButton('dokiv_share_button', { 4 title : " Share Dokiv",4 title : "Dokiv Share", 5 5 image : url + "/dokiv-button.png", 6 6 onclick: function (e) { … … 9 9 body: [{ 10 10 type: 'textbox', 11 label: ' Link Share Dokiv',11 label: 'Dokiv Share Link', 12 12 name: 'share_dokiv', 13 13 placeholder: 'Link Dokiv', … … 36 36 ], 37 37 onsubmit: function( e ) { 38 38 39 // check link have domian dokiv 39 40 if (e.data.share_dokiv.indexOf("https://share.dokiv.com") >= 0) { -
dokiv-sharing/trunk/dokiv_sharing.php
r2064958 r2071135 3 3 /* 4 4 Plugin Name: Dokiv Sharing for WP 5 Description: Add buttonsharing to Visual Editor6 Version: 1. 0.35 Description: Add sharing to Visual Editor 6 Version: 1.1.0 7 7 Author: Dokiv AB 8 8 Author URI: https://dokiv.com … … 35 35 function dokiv_custom_tinymce_plugin( $plugins ) { 36 36 $plugins['dokiv_share_button'] = plugin_dir_url(__FILE__) .'assets/js/dokiv_sharing.js'; 37 $plugins['dokiv_share_button_lightbox'] = plugin_dir_url(__FILE__) .'assets/js/dokiv_sharing_lightbox.js'; 37 38 return $plugins; 38 39 } … … 41 42 function dokiv_register_tinymce_buttons( $buttons ) { 42 43 array_push( $buttons, 'dokiv_share_button' ); 44 array_push( $buttons, 'dokiv_share_button_lightbox' ); 43 45 return $buttons; 44 46 } 45 47 46 /* 47 * Add New Block to Guntenberg 48 */ 49 // Hook: Editor assets. 50 //add_action( 'enqueue_block_editor_assets', 'gb_block_01_basic_editor_assets' ); 51 ///** 52 // * Enqueue the block's assets for the editor. 53 // * 54 // * `wp-blocks`: includes block type registration and related functions. 55 // * `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks. 56 // * `wp-i18n`: To internationalize the block's. text. 57 // * 58 // * @since 1.0.0 59 // */ 60 //function gb_block_01_basic_editor_assets() { 61 // // Scripts. 62 // wp_enqueue_script( 63 // 'gb-block-01-basic', // Handle. 64 // plugins_url( 'assets/js/dokiv_sharing_block.js', __FILE__ ), // Block.js: We register the block here. 65 // array( 'wp-blocks', 'wp-i18n', 'wp-element' ), // Dependencies, defined above. 66 // filemtime( plugin_dir_path( __FILE__ ) . 'dokiv_sharing_block.js' ) // filemtime — Gets file modification time. 67 // ); 68 // // Styles. 69 // wp_enqueue_style( 70 // 'gb-block-01-basic-editor', // Handle. 71 // plugins_url( 'assets/css/editor.css', __FILE__ ), // Block editor CSS. 72 // array( 'wp-edit-blocks' ), // Dependency to include the CSS after it. 73 // filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' ) // filemtime — Gets file modification time. 74 // ); 75 //} // End fucntion gb_block_01_basic_editor_assets(). 76 //// Hook: Frontend assets. 77 //add_action( 'enqueue_block_assets', 'gb_block_01_basic_block_assets' ); 78 ///** 79 // * Enqueue the block's assets for the frontend. 80 // * 81 // * @since 1.0.0 82 // */ 83 //function gb_block_01_basic_block_assets() { 84 // // Styles. 85 // wp_enqueue_style( 86 // 'gb-block-01-basic-frontend', // Handle. 87 // plugins_url( 'assets/css/style.css', __FILE__ ), // Block frontend CSS. 88 // array( 'wp-blocks' ), // Dependency to include the CSS after it. 89 // filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' ) // filemtime — Gets file modification time. 90 // ); 91 //} // End fucntion gb_block_01_basic_block_assets(). 48 //Import CSS and jQuery files 49 add_action('wp_enqueue_scripts', 'dokiv_sharing_scrips'); 50 function dokiv_sharing_scrips() { 51 wp_register_style( 'dokiv-sharing-fancybox-css', plugin_dir_url(__FILE__).'assets/css/jquery.fancybox.min.css' ); 52 wp_enqueue_style( 'dokiv-sharing-fancybox-css' ); 53 wp_enqueue_script( 'dokiv-sharing-fancybox-js', plugin_dir_url(__FILE__).'assets/js/jquery.fancybox.min.js', array( 'jquery' ) ); 54 } 92 55 93 56 //Add Field to Menu Admin 57 add_filter( 'wp_edit_nav_menu_walker', 'dokiv_filter_walker', 99 ); 58 function dokiv_filter_walker( $walker ){ 59 $walker = 'Dokiv_Menu_Item_Custom_Fields_Walker'; 60 if ( ! class_exists( $walker ) ) { 61 require_once plugin_dir_path(__FILE__) . 'libs/custom_walker_edit.php'; 62 } 63 return $walker; 64 } 65 require_once plugin_dir_path(__FILE__) . 'libs/menu_item_custom_fields.php'; 66 67 //Add lightbox for menu have dokiv sharing 68 function dokiv_add_lightbox_for_menu($items, $args) { 69 foreach( $items as $key => $item ) { 70 //Check item menu have sharing link 71 $dokiv_sharing_link = get_post_meta($item->ID,'menu-item-dokiv_sharing_link_field',true ); 72 $dokiv_sharing_bgcolor = get_post_meta($item->ID,'menu-item-dokiv_sharing_bgcolor_field',true ); 73 if ( empty( $dokiv_sharing_bgcolor ) ) $dokiv_sharing_bgcolor = 'fff'; else str_replace ('#', '', $dokiv_sharing_bgcolor); 74 if ( !empty( $dokiv_sharing_link ) && (strpos( $dokiv_sharing_link, 'share.dokiv.com') !== false) ) { 75 $item->url = $dokiv_sharing_link.'&onlyContent=true&bgcolor='.$dokiv_sharing_bgcolor; 76 $items[$key] = $item; 77 } 78 } 79 return $items; 80 } 81 add_filter('wp_nav_menu_objects', 'dokiv_add_lightbox_for_menu', 10, 2); 82 83 //Add data for fancybox 84 add_filter( 'nav_menu_link_attributes', 'dokiv_add_menu_atts', 10, 3 ); 85 function dokiv_add_menu_atts( $atts, $item, $args ) 86 { 87 $dokiv_sharing_link = get_post_meta($item->ID,'menu-item-dokiv_sharing_link_field',true ); 88 $dokiv_sharing_width = get_post_meta($item->ID,'menu-item-dokiv_sharing_width_field',true ); 89 if ( empty( $dokiv_sharing_width ) ) $dokiv_sharing_width = '400'; else str_replace ('px', '', $dokiv_sharing_width); 90 if ( !empty( $dokiv_sharing_link ) && (strpos( $dokiv_sharing_link, 'share.dokiv.com') !== false) ) { 91 $atts['data-fancybox'] = 'true'; 92 $atts['data-options'] = '{"type" : "iframe", "iframe" : {"preload" : false, "css" : {"width" : "'.$dokiv_sharing_width.'px"}}}'; 93 } 94 return $atts; 95 } -
dokiv-sharing/trunk/readme.txt
r2064958 r2071135 22 22 ##1.0.2 23 23 #Apply color background for sharing 24 ##1. 0.325 #Support Gutenberg24 ##1.1.0 25 #Support lightbox sharing for menus admin and Editor text
Note: See TracChangeset
for help on using the changeset viewer.