Plugin Directory

Changeset 2071135


Ignore:
Timestamp:
04/19/2019 08:10:47 AM (7 years ago)
Author:
richardlikipe
Message:

Update version 1.1.0 - Support lightbox

Location:
dokiv-sharing/trunk
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • dokiv-sharing/trunk/assets/js/dokiv_sharing.js

    r2064958 r2071135  
    22    tinymce.PluginManager.add('dokiv_share_button', function(editor, url) {
    33        editor.addButton('dokiv_share_button', {
    4             title : "Share Dokiv",
     4            title : "Dokiv Share",
    55            image : url + "/dokiv-button.png",
    66            onclick: function (e) {
     
    99                    body: [{
    1010                        type: 'textbox',
    11                         label: 'Link Share Dokiv',
     11                        label: 'Dokiv Share Link',
    1212                        name: 'share_dokiv',
    1313                        placeholder: 'Link Dokiv',
     
    3636                ],
    3737                    onsubmit: function( e ) {
     38                       
    3839                        // check link have domian dokiv
    3940                        if (e.data.share_dokiv.indexOf("https://share.dokiv.com") >= 0) {
  • dokiv-sharing/trunk/dokiv_sharing.php

    r2064958 r2071135  
    33/*
    44Plugin Name: Dokiv Sharing for WP
    5 Description: Add button sharing to Visual Editor
    6 Version:     1.0.3
     5Description: Add sharing to Visual Editor
     6Version:     1.1.0
    77Author:      Dokiv AB
    88Author URI:  https://dokiv.com
     
    3535function dokiv_custom_tinymce_plugin( $plugins ) {
    3636    $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';
    3738    return $plugins;
    3839}
     
    4142function dokiv_register_tinymce_buttons( $buttons ) {
    4243    array_push( $buttons, 'dokiv_share_button' );
     44    array_push( $buttons, 'dokiv_share_button_lightbox' );
    4345    return $buttons;
    4446}
    4547
    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
     49add_action('wp_enqueue_scripts', 'dokiv_sharing_scrips');
     50function 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}
    9255
    93  
     56//Add Field to Menu Admin
     57add_filter( 'wp_edit_nav_menu_walker', 'dokiv_filter_walker', 99 );
     58function 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}
     65require_once plugin_dir_path(__FILE__) . 'libs/menu_item_custom_fields.php'; 
     66
     67//Add lightbox for menu have dokiv sharing
     68function 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}
     81add_filter('wp_nav_menu_objects', 'dokiv_add_lightbox_for_menu', 10, 2);
     82
     83//Add data for fancybox
     84add_filter( 'nav_menu_link_attributes', 'dokiv_add_menu_atts', 10, 3 );
     85function 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  
    2222##1.0.2
    2323#Apply color background for sharing
    24 ##1.0.3
    25 #Support Gutenberg
     24##1.1.0
     25#Support lightbox sharing for menus admin and Editor text
Note: See TracChangeset for help on using the changeset viewer.