Plugin Directory

Changeset 1476083


Ignore:
Timestamp:
08/16/2016 10:27:14 PM (10 years ago)
Author:
codemacher
Message:

first dummy integration of mce button

Location:
cm-css-columns/trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • cm-css-columns/trunk/admin/Admin.php

    r1475941 r1476083  
    109109     */
    110110    wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/admin.js', array('jquery'), $this->version, false);
     111  }
     112  /**
     113   *
     114   * @param array $plugin_array
     115   * @return array
     116   */
     117  public function enqueue_mce_plugin_scripts($plugin_array) {
     118    $plugin_array['cm_css_columns'] = plugin_dir_url(__FILE__) . 'js/tinymce-cm-css-columns.js';
     119    return $plugin_array;
     120  }
     121
     122  public function register_mce_buttons($buttons) {
     123    array_push($buttons, 'separator', 'cm_css_columns');
     124    return $buttons;
    111125  }
    112126
  • cm-css-columns/trunk/admin/js/admin.js

    r1475941 r1476083  
    1 (function ($) {
    2     /**
    3      * All of the code for your admin-facing JavaScript source
    4      * should reside in this file.
    5      *
    6      * Note: It has been assumed you will write jQuery code here, so the
    7      * $ function reference has been prepared for usage within the scope
    8      * of this function.
    9      *
    10      * This enables you to define handlers, for when the DOM is ready:
    11      *
    12      * $(function() {
    13      *
    14      * });
    15      *
    16      * When the window is loaded:
    17      *
    18      * $( window ).load(function() {
    19      *
    20      * });
    21      *
    22      * ...and/or other possibilities.
    23      *
    24      * Ideally, it is not considered best practise to attach more than a
    25      * single DOM-ready or window-load handler for a particular page.
    26      * Although scripts in the WordPress core, Plugins and Themes may be
    27      * practising this, we should strive to set a better example in our own work.
    28      */
    29 })(jQuery);
  • cm-css-columns/trunk/includes/CorePlugin.php

    r1475941 r1476083  
    9595        $this->set_locale();
    9696        $this->define_admin_hooks();
     97        $this->define_admin_filter();
    9798        $this->define_public_hooks();
    9899    }
     
    152153
    153154    private function define_admin_filter() {
     155        // Check if the logged in WordPress User can edit Posts or Pages
     156        // If not, don't register our TinyMCE plugin
     157        /*if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
     158            return;
     159        }*/
     160
     161        // Check if the logged in WordPress User has the Visual Editor enabled
     162        // If not, don't register our TinyMCE plugin
     163        /*if (get_user_option('rich_editing') !== 'true') {
     164            return;
     165        }*/
     166       
     167        $this->loader->add_filter('mce_external_plugins', $this->plugin_admin, 'enqueue_mce_plugin_scripts',10,1);
     168        $this->loader->add_filter('mce_buttons', $this->plugin_admin, 'register_mce_buttons',10,1);
    154169    }
    155170
Note: See TracChangeset for help on using the changeset viewer.