public function frontendEnqueueCss() { $css = [Functions::buildActionName('awesome') => ['deps' => [], 'url' => $this->getAwesomeURL(), 'version' => null], Functions::buildActionName('frontend') => ['deps' => [Functions::buildActionName('awesome')], 'url' => Url::getCssUrl('frontend')]]; foreach ($css as $k => $v) { \wp_enqueue_style($k, $v['url'], isset($v['deps']) ? $v['deps'] : [], $this->getVersion($v)); } }
public function backendEnqueueScripts() { $js = [Functions::buildActionName('backend') => ['url' => Url::getJsUrl('backend')]]; foreach ($js as $k => $v) { \wp_enqueue_script($k, $v['url'], isset($v['deps']) ? $v['deps'] : [], $this->getVersion($v)); } }
public static function getAjax($action = null, array $args = []) { $url = static::getAdmin('admin-ajax.php'); if (!$action) { return $url; } $action = Functions::buildActionName($action); if (empty($args)) { return "{$url}?action={$action}"; } return "{$url}?action={$action}&" . http_build_query($args); }
protected static function _saveOpts() { if (empty(static::$opts)) { static::$opts = static::getOpts(); } if (isset($_POST['restore'])) { static::$opts = []; \delete_option(Core::ID); } else { static::$opts = \apply_filters(Functions::buildActionName('addonSaveOpts'), []); Other::updateOption(Core::ID, static::$opts); } return static::$opts; }
public static function getUserMeta(...$args) { if (class_exists(InnThemeUser::class) && method_exists(InnThemeUser::class, 'getUserMeta')) { return call_user_func_array([InnThemeUser::class, 'getUserMeta'], $args); } if (isset($args[3]) && $args[3]) { unset($args[3]); return Functions::metaToJson(call_user_func_array('\\get_user_meta', $args)); } static $cache = []; $cacheID = md5(json_encode($args)); if (!isset($cache[$cacheID])) { $cache[$cacheID] = Functions::metaToJson(call_user_func_array('\\get_user_meta', $args)); } return $cache[$cacheID]; }
protected function setOptsSave($method = 'saveOpts') { \add_filter(Functions::buildActionName('addonSaveOpts'), function (array $opts = []) use($method) { $opts[static::getOptID()] = call_user_func([$this, $method]); return $opts; }); }
public function displayBackend() { ?> <div class="wrap <?php echo Core::ID; ?> -wrap"> <form class="backend-fm <?php echo Core::ID; ?> -backend-fm" method="post" action="<?php echo Url::getAjax(static::getOptID(), ['_nonce' => Security::createNonce()]); ?> "> <div class="tab-nav-container <?php echo Core::ID; ?> -tab-nav-container"></div> <div class="tab-body"> <?php $settings = \apply_filters(Functions::buildActionName('backendSettings'), []); ksort($settings); foreach ($settings as $legend => $setting) { ?> <fieldset> <legend class="button button-primary"> <i class="fa fa-fw fa-<?php echo $setting['icon']; ?> "></i> <?php echo $setting['title']; ?> </legend> <?php call_user_func($setting['content']); ?> </fieldset> <?php } ?> </div> <p> <input type="hidden" name="_nonce" value="<?php echo Security::createNonce(); ?> "> <button id="submit" type="submit" class="backend-submit button button-primary"><i class="fa fa-check"></i> <span class="tx"><?php echo L10n::__('Save'); ?> </span></button> <label for="options-restore" class="label-options-restore" title="<?php echo L10n::__('Something error with plugin? Try to restore. Be careful, plugin options will be cleared up!'); ?> "> <input id="options-restore" name="restore" type="checkbox" value="1"/> <?php echo L10n::__('Restore to default options'); ?> <i class="fa fa-question-circle"></i> </label> </p> </form> </div> <?php }
public static function getThumbnailURL($postID, $size = 'thumbnail', $placeholderURL = null) { if (!$placeholderURL) { $placeholderURL = ImgPlaceholder::getThumbnailPlaceholderURL(); } $imgURL = null; /** check sinapicv2 thumbnail */ if (class_exists('\\sinapicv2\\sinapicv2')) { $imgURL = \sinapicv2\sinapicv2::get_post_thumbnail_url($postID, true); } else { if (\has_post_thumbnail($postID)) { $thumbnailID = \get_post_thumbnail_id($postID); $imgURL = \wp_get_attachment_image_src($thumbnailID, $size)[0]; if ($size !== 'thumbnail') { if (\wp_get_attachment_image_src($thumbnailID, 'full')[0] === $imgURL) { $imgURL = \wp_get_attachment_image_src($thumbnailID, 'thumbnail')[0]; } } } } if (!$imgURL) { $post = static::getPost($postID); $imgURL = $post ? Functions::getImgURL($post->post_content) : false; unset($post); } if (!$imgURL) { $imgURL = $placeholderURL; } return $imgURL; //if (\is_ssl() && stripos($imgURL, 'https://')) { //} //return stripos(Other::getBlogInfo('home')) Url::esc($imgURL); }
public static function isOptsPage() { $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING); return $page === Functions::buildActionName(Options::URL_ID) && User::currentUserCan('manage_options') && static::isAdmin(); }