'appointlet', 'description' => __( 'Appointlet button users can click to open your scheduler.', 'en_US' ) ); //$control_options = array( 'width' => 245, 'height' => 400 ); parent::__construct('appointlet', __( 'Appointlet', 'en_US' ), $widget_options); // Register admin styles and scripts add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) ); // Register site styles and scripts //add_action( 'wp_enqueue_scripts', array( $this, 'register_widget_styles' ) ); //add_action( 'wp_enqueue_scripts', array( $this, 'register_widget_scripts' ) ); } // end constructor /*--------------------------------------------------*/ /* Widget API Functions /*--------------------------------------------------*/ /** * Outputs the content of the widget. * * @param array args The array of form elements * @param array instance The current instance of the widget */ public function widget( $args, $instance ) { extract( $args, EXTR_SKIP ); echo $before_widget; include( plugin_dir_path( __FILE__ ) . '/views/widget.php' ); echo $after_widget; } /** * Processes the widget's options to be saved. * * @param array new_instance The previous instance of values before the update. * @param array old_instance The new instance of values to be generated via the update. */ public function update( $new_instance, $old_instance ) { $instance = $new_instance; unset($instance['appointlet_button_custom']); return $instance; } /** * Generates the administration form for the widget. * * @param array instance The array of keys and values for the widget. */ public function form( $instance ) { $defaults = array('button' => '//dje0x8zlxc38k.cloudfront.net/buttons/booknow-red.png'); $instance = wp_parse_args((array)$instance, $defaults); extract($instance); include( plugin_dir_path(__FILE__) . '/views/admin.php' ); } /*--------------------------------------------------*/ /* Public Functions /*--------------------------------------------------*/ /** * Loads the Widget's text domain for localization and translation. */ public function widget_textdomain() { // TODO be sure to change 'widget-name' to the name of *your* plugin load_plugin_textdomain( 'en_US', false, plugin_dir_path( __FILE__ ) . '/lang/' ); } /** * Fired when the plugin is activated. * * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog. */ public function activate( $network_wide ) { } /** * Fired when the plugin is deactivated. * * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog */ public function deactivate( $network_wide ) { } /** * Registers and enqueues admin-specific styles. */ public function register_admin_styles() { wp_enqueue_style( 'appointlet-admin-styles', plugins_url( 'appointlet/css/admin.css' ) ); } /** * Registers and enqueues admin-specific JavaScript. */ public function register_admin_scripts() { wp_enqueue_script( 'appointlet-admin-script', plugins_url( 'appointlet/js/admin.js' ) ); } /** * Registers and enqueues widget-specific styles. */ public function register_widget_styles() { wp_enqueue_style( 'appointlet-widget-styles', plugins_url( 'appointlet/css/widget.css' ) ); } /** * Registers and enqueues widget-specific scripts. */ public function register_widget_scripts() { wp_enqueue_script( 'appointlet-script', plugins_url( 'appointlet/js/widget.js' ) ); } public function get_buttons() { return array( __('red') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-red.png", __('green') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-green.png", __('blue') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-blue.png", __('gray') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-gray.png", __('brown') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-brown.png", __('pink') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-pink.png", __('silver') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-silver.png", __('yellow') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-yellow.png", __('orange') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-orange.png", __('purple') => "//dje0x8zlxc38k.cloudfront.net/buttons/booknow-purple.png", ); } } add_action( 'widgets_init', create_function( '', 'register_widget("Appointlet_Widget");' ) );