Example #1
0
 /**
  * CSS, JAVASCRIPT, THICKBOX
  * ================================ */
 function enqueueStylesForAdminPages()
 {
     global $pagenow, $post;
     $MabBase = MAB();
     $is_mab_post_type = true;
     if (!is_object($post)) {
         $is_mab_post_type = false;
     } else {
         $is_mab_post_type = $MabBase->is_mab_post_type($post->post_type);
     }
     //don't load if post content type doesn't require it.
     if ($MabBase->is_allowed_content_type()) {
         wp_enqueue_style('mab-admin-style');
     } elseif ($is_mab_post_type || $pagenow == 'admin.php') {
         /* create custom buttons stylesheet if its not there */
         if (!file_exists(mab_get_custom_buttons_stylesheet_path())) {
             $MabButton = MAB('button');
             $MabButton->writeConfiguredButtonsStylesheet($MabButton->getConfiguredButtons(), '');
         }
         //load buttons stylesheet
         wp_enqueue_style('mab-custom-buttons', mab_get_custom_buttons_stylesheet_url());
         //load admin stuff stylesheet
         wp_enqueue_style('mab-admin-style');
         //used for color pickers
         wp_enqueue_style('farbtastic');
     }
 }
Example #2
0
 static function loadCustomCss($style, $templateObj)
 {
     $actionBoxObj = $templateObj->_actionbox_obj;
     $actionBoxId = $actionBoxObj->getId();
     /** LOAD CUSTOM CSS **/
     //get stylesheet which should contain only CSS in Custom CSS box under Design Setting: Custom CSS
     $custom_css_stylesheet = mab_get_actionbox_stylesheet_path($actionBoxId);
     //create stylesheet file if its not created yet
     if (!file_exists($custom_css_stylesheet) || trim(mab_get_actionbox_stylesheet_contents($actionBoxId)) == '') {
         mab_create_actionbox_stylesheet($actionBoxId);
     }
     if (file_exists($custom_css_stylesheet)) {
         //actionbox specific stylesheet
         wp_enqueue_style("mab-actionbox-style-{$actionBoxId}", mab_get_actionbox_stylesheet_url($actionBoxId), array(), filemtime($custom_css_stylesheet));
     }
     /** LOAD BUTTONS CSS **/
     /* create custom buttons stylesheet if its not there */
     if (!file_exists(mab_get_custom_buttons_stylesheet_path())) {
         $MabButton = MAB('button');
         $MabButton->writeConfiguredButtonsStylesheet($MabButton->getConfiguredButtons(), '');
     }
     // load buttons stylesheet.
     // we do this way to ensure that mab-custom-buttons-css stylesheet will always be the last
     // to load. this is especially important when two action boxes use custom buttons.
     if (wp_style_is('mab-custom-buttons-css', 'queue')) {
         //dequeue the style so we can enqueue it to footer
         wp_dequeue_style('mab-custom-buttons-css');
     }
     $buttons_stylesheet = mab_get_custom_buttons_stylesheet_path();
     if (file_exists($buttons_stylesheet)) {
         wp_enqueue_style('mab-custom-buttons-css', mab_get_custom_buttons_stylesheet_url(), array(), filemtime($buttons_stylesheet));
     }
     /** LOAD MISC **/
 }
Example #3
0
 /**
  * Write Configured Buttons Stylesheet
  * @param array $newvalue buttons settings
  * @param any $oldvalue unused
  */
 function writeConfiguredButtonsStylesheet($newvalue, $oldvalue)
 {
     $css = '';
     if (is_array($newvalue)) {
         foreach ($newvalue as $key => $button) {
             $css .= strip_tags($this->getButtonCode($button, $key));
         }
     }
     $handle = @fopen(mab_get_custom_buttons_stylesheet_path(), 'w');
     @fwrite($handle, mab_minify_css($css));
     @fclose($handle);
     return $newvalue;
 }