/** * Returns a shortcode html markup. * * @since 1.0.0 * @return string */ public function render($attr, $content) { if (!$this->connected) { $this->assets(array($attr), true, false); $this->scripts->connect(true); $this->styles->connect(true); } // fix for compability global $post; if (!empty($post) && !empty($this->shortcodeName)) { $foundShortcodes = get_post_meta($post->ID, self::$metaKeyShorcodeAssetsForPosts, true); if ($foundShortcodes && !is_array($foundShortcodes)) { $shortcodes = $this->shortcodeName; if (!is_array($shortcodes)) { $shortcodes = array($this->shortcodeName); } $foundShortcodes = array(); $foundShortcodes[$shortcodes[0]] = array(); $foundShortcodes[$shortcodes[0]][] = $attr; update_post_meta($post->ID, self::$metaKeyShorcodeAssetsForPosts, $foundShortcodes); } } ob_start(); $this->html($attr, $content); $html = ob_get_clean(); return $html; }
/** * Includes scripts and styles for a metabox. * * @since 1.0.0 * @return void */ public function includeScriptsAndStyles() { global $post; if ($this->scripts->isEmpty() && $this->styles->isEmpty()) { return; } if (!in_array($post->post_type, $this->postTypes)) { return; } $this->scripts->connect(); $this->styles->connect(); }
/** * Actions that includes registered fot this type scritps and styles. * @global type $post * @param type $hook */ public function actionAdminScripts($hook) { global $post; if (!in_array($hook, array('post.php', 'post-new.php'))) { return; } if ($post->post_type != $this->name) { return; } if ($this->scripts->isEmpty() && $this->styles->isEmpty()) { return; } $this->scripts->connect(); $this->styles->connect(); }