Пример #1
0
    public function displayBackend()
    {
        ?>
        <table class="form-table">
        <tbody>
        <tr>
            <th><?php 
        echo L10n::__('Control');
        ?>
</th>
            <td>
                <a
                    href="<?php 
        echo Url::getAjax(static::getOptID(), ['_nonce' => Security::createNonce()]);
        ?>
"
                    target="_blank"
                    class="button button-primary"
                >
                    <i class="fa fa-refresh"></i>
                    <?php 
        echo L10n::__('Flush cache');
        ?>
                </a>
            </td>
        </tr>
        </tbody>
        </table>
        <?php 
    }
Пример #2
0
 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));
     }
 }
Пример #3
0
 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));
     }
 }
Пример #4
0
 protected function getConf()
 {
     $conf = ['ID' => Core::ID, 'ajaxURL' => Url::getAjax(), 'lang' => ['loading' => L10n::__('Loading, please wait...'), 'error' => L10n::__('Sorry, server is busy now, can not respond your request, please try again later.'), 'close' => L10n::__('Close'), 'ok' => L10n::__('OK')]];
     if (Condition::isAdmin()) {
         $conf['_nonce'] = Security::createNonce();
     }
     return \apply_filters(Functions::buildActionName('dynamicConf'), $conf);
 }
Пример #5
0
 public static function checkReferer($limitURL = null)
 {
     if (!$limitURL) {
         $limitURL = Url::getHome();
     }
     if (!isset($_SERVER['HTTP_REFERER']) || stripos($_SERVER['HTTP_REFERER'], $limitURL) !== 0) {
         die(header($_SERVER['SERVER_PROTOCOL'] . ' 403', true));
     }
 }
Пример #6
0
 public static function getTermURL($termID)
 {
     static $cache = [];
     if (isset($cache[$termID])) {
         return $cache[$termID];
     }
     $cache[$termID] = Url::esc(\get_term_link($termID));
     return $cache[$termID];
 }
Пример #7
0
    public function displayBackend()
    {
        $isOem = isset($metaTrans['oem']) ? true : false;
        $metaTrans = isset($metaTrans['oem']) ? $metaTrans['oem'] : Core::getMetaTranslation();
        ?>
        <table class="form-table">
        <tbody>
        <?php 
        $item = function ($title, $value) {
            ?>
            <tr>
            <th scope="row"><?php 
            echo $title;
            ?>
</th>
            <td><p><?php 
            echo $value;
            ?>
</p></td>
            </tr>
            <?php 
        };
        $item(L10n::__('Plugin name'), $metaTrans['name']);
        $item(L10n::__('Plugin version'), Other::getPlugin('Version'));
        $item(L10n::__('Plugin description'), $metaTrans['des']);
        $item(L10n::__('Plugin author'), $metaTrans['author']);
        $item(L10n::__('Plugin homepage'), '<a href="' . $metaTrans['pluginURL'] . '" target="_blank">' . $metaTrans['pluginURL'] . '</a>');
        $item(L10n::__('Author site'), '<a href="' . $metaTrans['authorURL'] . '" target="_blank">' . $metaTrans['authorURL'] . '</a>');
        ?>
        <tr>
            <th scope="row"><?php 
        echo L10n::__('Feedback &amp; technical support');
        ?>
</th>
            <td>

                <?php 
        if (isset($metaTrans['email'])) {
            ?>
                    <p><?php 
            echo L10n::__('E-Mail');
            ?>
 <a href="mailto:<?php 
            echo $metaTrans['email'];
            ?>
"><?php 
            echo $metaTrans['email'];
            ?>
</a></p>
                <?php 
        }
        ?>

                <?php 
        if (isset($metaTrans['qqGroup'])) {
            ?>
                    <p><?php 
            echo L10n::__('QQ group');
            ?>
                        <?php 
            if (isset($metaTrans['qqGroup']['link'])) {
                ?>
                            <a target="_blank" href="<?php 
                echo $metaTrans['qqGroup']['link'];
                ?>
"><?php 
                echo $metaTrans['qqGroup']['number'];
                ?>
</a>
                        <?php 
            } else {
                ?>
                            <?php 
                echo $metaTrans['qqGroup']['number'];
                ?>
                        <?php 
            }
            ?>
                    </p>
                <?php 
        }
        ?>
            </td>
        </tr>
        <?php 
        if (!$isOem) {
            ?>
            <tr>
                <th scope="row"><?php 
            echo L10n::__('Donate');
            ?>
</th>
                <td>
                    <p>
                        <!-- paypal -->
                        <a id="paypal_donate" href="<?php 
            echo Url::getAjax(static::getOptID());
            ?>
" title="<?php 
            echo L10n::__('Donation via Paypal');
            ?>
" target="_blank">
                            <img src="//ws2.sinaimg.cn/large/686ee05djw1ella1kv74cj202o011wea.jpg" alt="<?php 
            echo L10n::__('Donation via Paypal');
            ?>
" width="96" height="37"/>
                        </a>
                        <!-- alipay -->
                        <a id="alipay_donate" target="_blank" href="//ws3.sinaimg.cn/mw600/686ee05djw1eihtkzlg6mj216y16ydll.jpg" title="<?php 
            echo L10n::__('Donation via Alipay');
            ?>
">
                            <img width="96" height="37" src="//ws1.sinaimg.cn/large/686ee05djw1ellabpq9euj202o011dfm.jpg" alt="<?php 
            echo L10n::__('Donation via Alipay');
            ?>
"/>
                        </a>
                        <!-- wechat -->
                        <a id="wechat_donate" target="_blank" href="//ws4.sinaimg.cn/mw600/686ee05djw1exukpkk4fwj20fr0f940r.jpg" title="<?php 
            echo L10n::__('Donation via Wechat');
            ?>
">
                            <img width="96" height="37" src="//ws3.sinaimg.cn/large/686ee05djw1exul2142tvj202o0113ya.jpg" alt="<?php 
            echo L10n::__('Donation via Wechat');
            ?>
"/>
                        </a>
                    </p>
                </td>
            </tr>
        <?php 
        } else {
            ?>
            <tr>
                <th scope="row"><?php 
            echo L10n::__('Plugin core');
            ?>
</th>
                <td><a href="<?php 
            echo $metaTrans['core']['url'];
            ?>
" target="_blank"><?php 
            echo $metaTrans['core']['name'];
            ?>
</a></td>
            </tr>
        <?php 
        }
        ?>
        </tbody>
        </table>
        <?php 
    }
Пример #8
0
 public static function getAuthorPostsURL($userID)
 {
     if (class_exists(InnThemeUser::class) && method_exists(InnThemeUser::class, 'getAuthorPostsURL')) {
         InnThemeUser::getAuthorPostsURL($userID);
     }
     static $cache = [];
     if (isset($cache[$userID])) {
         return $cache[$userID];
     }
     $cache[$userID] = Url::esc(\get_author_posts_url($userID));
     return $cache[$userID];
 }
Пример #9
0
 public static function getURL()
 {
     return Url::getAdmin('admin.php?page=' . Functions::buildActionName(static::URL_ID));
 }
Пример #10
0
    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 
    }
Пример #11
0
 public static function getPermalink($postID, $leavename = false)
 {
     static $cache = [];
     if (isset($cache[$postID])) {
         return $cache[$postID];
     }
     global $post;
     if (!isset($post->ID) || $post->ID != $postID) {
         $p = static::getPost($postID);
     } else {
         $p = $post;
     }
     $rewritecode = ['%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename ? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename ? '' : '%pagename%'];
     if ($p->post_type == 'page') {
         return Url::esc(\get_page_link($p, $leavename));
     } elseif ($p->post_type == 'attachment') {
         return Url::esc(\get_attachment_link($p, $leavename));
     } elseif (in_array($p->post_type, \get_post_types(['_builtin' => false]))) {
         return Url::esc(\get_post_permalink($p, $leavename));
     }
     $permalink = Other::getOption('permalink_structure');
     $permalink = \apply_filters('pre_post_link', $permalink, $p, $leavename);
     if ('' != $permalink && !in_array($p->post_status, ['draft', 'pending', 'auto-draft', 'future'])) {
         $unixtime = strtotime($p->post_date);
         $category = '';
         if (strpos($permalink, '%category%') !== false) {
             $cats = Category::getTheCategory($p->ID);
             if ($cats) {
                 usort($cats, '_usort_terms_by_ID');
                 // order by ID
                 /**
                  * Filter the category that gets used in the %category% permalink token.
                  *
                  * @since 3.5.0
                  *
                  * @param stdClass $cat  The category to use InnStudio\Poil10n\in the permalink.
                  * @param array    $cats Array of all categories associated with the post.
                  * @param WP_Post  $post The post in question.
                  */
                 $category_object = \apply_filters('post_link_category', $cats[0], $cats, $p);
                 $category_object = \get_term($category_object, 'category');
                 $category = $category_object->slug;
                 if ($parent = $category_object->parent) {
                     $category = \get_category_parents($parent, false, '/', true) . $category;
                 }
             }
             // show default category in permalinks, without
             // having to assign it explicitly
             if (empty($category)) {
                 $default_category = \get_term(Other::getOption('default_category'), 'category');
                 $category = \is_wp_error($default_category) ? '' : $default_category->slug;
             }
         }
         $author = '';
         if (strpos($permalink, '%author%') !== false) {
             $authordata = User::getUserdata($p->post_author);
             $author = $authordata->user_nicename;
         }
         $date = explode(" ", date('Y m d H i s', $unixtime));
         $rewritereplace = array($date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $p->post_name, $p->ID, $category, $author, $p->post_name);
         $permalink = Url::getHome(str_replace($rewritecode, $rewritereplace, $permalink));
         $permalink = \user_trailingslashit($permalink, 'single');
     } else {
         // if they're not using the fancy permalink option
         $permalink = Url::getHome() . '?p=' . $p->ID;
     }
     /**
      * Filter the permalink for a post.
      *
      * Only applies to posts with post_type of 'post'.
      *
      * @since 1.5.0
      *
      * @param string  $permalink The post's permalink.
      * @param WP_Post $post      The post in question.
      * @param bool    $leavename Whether to keep the post name.
      */
     $cache[$postID] = Url::esc(\apply_filters('post_link', $permalink, $p, $leavename));
     unset($p);
     return $cache[$postID];
 }