Plugin Directory

Changeset 1250425


Ignore:
Timestamp:
09/21/2015 03:11:15 PM (11 years ago)
Author:
cdecou
Message:

Version 0.2, add plugin menu

Location:
custom-field-menu/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • custom-field-menu/trunk/custom-field-menu.php

    r1247419 r1250425  
    33Plugin Name: Custom Field Menu
    44Plugin URL: http://clement-decou.olympe.in
    5 Description: Add cutom fields to menu items
    6 Version: 0.1.1
     5Description: Add custom fields to menu items
     6Version: 0.2
    77Author: Clément Décou
    88Author URI: http://clement-decou.olympe.in
     
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111*/
    12 
     12require_once(plugin_dir_path( __FILE__ ).'/classes/admin/PluginAdminPage.php');
    1313class custom_field_menu {
    1414
     
    2121     */
    2222    function __construct() {
     23
     24        register_activation_hook(__FILE__, array($this, 'cfm_init'));
    2325
    2426        // load the plugin translation files
     
    3436        add_filter( 'wp_edit_nav_menu_walker', array( $this, 'cfm_edit_walker'), 10, 2 );
    3537
    36         add_action('admin_enqueue_scripts', array($this, 'cm_load_media'));
     38        add_action('admin_enqueue_scripts', array($this, 'cfm_load_media'));
     39
     40        add_action('admin_menu', array($this, 'cfm_admin_menu'));
     41        add_action('admin_init', array($this, 'cfm_register_settings'));
    3742
    3843
    3944    } // end constructor
     45
     46    /**
     47     * Init the plugin (options etc.)
     48     *
     49     * @access      public
     50     * @since       0.2
     51     * @return      void
     52    */
     53
     54    function cfm_init(){
     55        PluginAdminPage::defaultOption();
     56    }
    4057
    4158
     
    4764     * @return void
    4865     */
    49     public function cm_load_media(){
     66    public function cfm_load_media(){
    5067        global $pagenow;
    5168        if($pagenow == "nav-menus.php"){
    5269            wp_enqueue_media();
    53             wp_register_script('cm-admin-js', WP_PLUGIN_URL.'/custom-field-menu/js/cm_script.js', array('jquery'));
    54             wp_enqueue_script('cm-admin-js');
     70            wp_register_script('cfm-admin-js', WP_PLUGIN_URL.'/custom-field-menu/js/cfm_script.js', array('jquery'));
     71            wp_localize_script('cfm-admin-js', 'titleBox', get_option('title_box') );
     72            wp_localize_script('cfm-admin-js', 'textButton', get_option('text_button') );
     73            wp_enqueue_script('cfm-admin-js');
    5574        }
    5675    }
     
    110129    }
    111130
     131    /**
     132     * Add admin menu
     133     *
     134     * @access      public
     135     * @since       0.2
     136     * @return      void
     137    */
     138    function cfm_admin_menu(){
     139        new PluginAdminPage();
     140    }
     141
     142    /**
     143     * Register all settings of the plugin
     144     *
     145     * @access      public
     146     * @since       0.2
     147     * @return      void
     148    */
     149    function cfm_register_settings(){
     150        PluginAdminPage::setupOption();
     151    }
     152
    112153}
    113154
  • custom-field-menu/trunk/edit_custom_walker.php

    r1247419 r1250425  
    179179                        <?php _e( 'Url' ); ?><br />
    180180                        <input type="text" id="edit-menu-item-urlimg-<?php echo $item_id; ?>" class="widefat code edit-menu-item-custom" name="menu-item-urlimg[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->urlimg ); ?>" />
    181                         <input type="button" class="upload_image_button button button-primary" value="Choose image">
     181                        <input type="button" class="upload_image_button button button-primary" value="<?php echo get_option('title_box') ?>">
    182182                    </label>
    183183                </p>
  • custom-field-menu/trunk/readme.txt

    r1247422 r1250425  
    33Tags: custom field, CMS, menu, types, field, item, item-menu, custom
    44Requires at least: 3.5
    5 Stable tag: 0.1.1
     5Stable tag: 0.1
    66Tested up to: 4.3
    77License: GPLv2
     
    2323
    2424== Changelog ==
     25
     26= 0.2 =
     27* Add menu for the plugin
     28* For an image field you can change the title of the media box and the text button
     29* Change PHP Structure
    2530
    2631= 0.1.1 =
Note: See TracChangeset for help on using the changeset viewer.