/**
  * Add any scripts that might be needed to format the shortcode
  */
 public function addScript()
 {
     if (!self::$addedAlready) {
         self::$addedAlready = true;
         // wp_register_script('my-script', plugins_url('js/my-script.js', __FILE__), array('jquery'), '1.0', true);
         // wp_print_scripts('my-script');
     }
 }
示例#2
0
 /**
  * Add any plugin applicaiton actions or filters
  */
 public function addActionsAndFilters()
 {
     include_once 'topline_PropertiesShortcode.php';
     include_once 'topline_FloorplanShortcode.php';
     // Add options administration page
     // http://plugin.michael-simpson.com/?page_id=47
     add_action('admin_menu', array(&$this, 'createSettingsMenu'));
     // Example adding a script & style just for the options administration page
     if (strpos($_SERVER['REQUEST_URI'], $this->getSettingsSlug()) !== false) {
         wp_enqueue_script('topline-option-scripts', plugins_url('/js/topline-options.js', __FILE__), array('jquery'));
         wp_enqueue_style('topline-option-styles', plugins_url('/css/topline.css', __FILE__));
     }
     // Add Actions & Filters
     add_action('refreshToplineToken', 'refreshFeed');
     add_filter('single_template', [$this, 'useCustomSingleTemplate']);
     /* Action that overrides saving custom post types */
     add_action('save_post', [$this, 'save_custom_post_meta']);
     // Adding scripts & styles for single property and floorplan views
     wp_enqueue_style('topline-global', plugins_url('/css/topline-shortcodes.css', __FILE__));
     // Register short codes
     $propertyShortcode = new topline_PropertiesShortcode();
     $propertyShortcode->register('propertieslist');
     $floorplanShortcode = new topline_FloorplanShortcode();
     $floorplanShortcode->register('floorplanlist');
     // Register AJAX hooks
     // e.g. ajaxACTION would be the name of your ajax method to accept the request
     // The ACTION portion of your method is your unique identifier
     // Let's say it's now 'MyAjaxActionName'
     // In ajaxMyAjaxActionName method:
     // You get the plain url like so: $plainUrl = $this->getAjaxUrl('MyAjaxActionName');
     // Send query variables: $urlWithId = $this->getAjaxUrl('MyAjaxActionName&id=MyId');
     // cont. but more sophisticated:
     // $parametrizedUrl = $this->getAjaxUrl('MyAjaxActionName&id=%s&lat=%s&lng=%s');
     // $urlWithParamsSet = sprintf($parametrizedUrl, urlencode($myId), urlencode($myLat), urlencode($myLng));
     // add_action('wp_ajax_ACTION', array(&$this, 'ajaxACTION'));
     // add_action('wp_ajax_nopriv_ACTION', array(&$this, 'ajaxACTION')); // optional for non-signed in users
 }