function popmake_tiny_mce_styles_dropdown_options($initArray)
{
    // Add Popup styles to styles dropdown
    $styles = !empty($initArray['style_formats']) && is_array(json_decode($initArray['style_formats'])) ? json_decode($initArray['style_formats']) : array();
    foreach (get_all_popups()->posts as $popup) {
        $styles[] = array('title' => "Open Popup - {$popup->post_title}", 'inline' => 'span', 'classes' => "popmake-{$popup->ID}");
    }
    $initArray['style_formats'] = json_encode($styles);
    return $initArray;
}
Example #2
0
 /**
  * Add Dropcap options to the style_formats drop down.
  */
 public static function format_options($settings)
 {
     /* Our Own Custom Options */
     $popup_formats = array();
     foreach (get_all_popups()->posts as $popup) {
         $popup_formats[] = array('title' => $popup->post_title, 'inline' => 'span', 'classes' => "popmake-{$popup->ID}");
     }
     $new_formats = array(array('title' => __('Popup Trigger', 'popup-maker'), 'items' => $popup_formats));
     /* Check if custom "style_formats" is enabled */
     if (isset($settings['style_formats'])) {
         /* Get old style_format config */
         $old_formats = json_decode($settings['style_formats']);
         /* Merge it with our own */
         $new_formats = array_merge($new_formats, $old_formats);
     } else {
         $new_formats = array_merge(self::default_formats(), $new_formats);
     }
     /* Add it in tinymce config as json data */
     $settings['style_formats'] = json_encode($new_formats);
     return $settings;
 }