Example #1
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);
 }
Example #2
0
 public static function getMetaTranslation($key = null)
 {
     $data = ['name' => L10n::__('Poi Author'), 'pluginURL' => L10n::__('https://inn-studio.com/poiauthor'), 'authorURL' => L10n::__('https://inn-studio.com'), 'author' => L10n::__('INN STUDIO'), 'qqGroup' => ['number' => '170306005', 'link' => 'https://jq.qq.com/?_wv=1027&k=41RRWxk'], 'email' => '*****@*****.**', 'edition' => L10n::__('Professional edition'), 'des' => L10n::__('A better performance author meta box instead of the build-in of WordPress.')];
     if ($key) {
         return isset($data[$key]) ? $data[$key] : false;
     }
     return $data;
 }
Example #3
0
 public function dynamicConfAdmin(array $conf)
 {
     if (Other::getCurrentScreen()->base !== 'post') {
         return $conf;
     }
     global $post;
     $conf[static::getOptID()] = ['id' => Functions::buildActionName(static::getOptID()), 'lang' => ['typeAuthorNameForSearch' => L10n::__('Type author name for search'), 'authorId' => L10n::__('Author ID')], 'postId' => $post->ID, 'authorId' => $post->post_author, 'authorName' => User::getTheAuthorMeta('display_name', $post->post_author)];
     return $conf;
 }
Example #4
0
 public function filterUpgraderSourceSelection($source, $remoteSource = null, $upgrader = null)
 {
     if ($this->last != Core::$basename) {
         return $source;
     }
     $correctedSource = $remoteSource . '/' . $this->last . '/';
     if (rename($source, $correctedSource)) {
         return $correctedSource;
     } else {
         $upgrader->skin->feedback(L10n::__('Unable to rename downloaded plugin.'));
         return new \WP_Error();
     }
 }
Example #5
0
 public static function getHumanDate($timestamp)
 {
     $text = '';
     $t = Other::getCurrentTime('timestamp') - $timestamp;
     switch ($t) {
         /**
          * in 1 minu, just now
          */
         case $t < 60:
             $text = L10n::__('Just');
             break;
             /**
              * in 1 hours, 60 * 60 = 3600
              */
         /**
          * in 1 hours, 60 * 60 = 3600
          */
         case $t < 3600:
             $text = sprintf(L10n::__('%dmin ago'), floor($t / 60));
             break;
             /**
              * in 1 day, 60 * 60 * 24 = 86400
              */
         /**
          * in 1 day, 60 * 60 * 24 = 86400
          */
         case $t < 86400:
             $text = sprintf(L10n::__('%dh ago'), floor($t / 3600));
             break;
             /**
              * in 1 month, 60 * 60 * 24 * 30 = 2592000
              */
         /**
          * in 1 month, 60 * 60 * 24 * 30 = 2592000
          */
         case $t < 2592000:
             $text = sprintf(L10n::__('%dd ago'), floor($t / 86400));
             break;
             /**
              * in 1 year, 60 * 60 * 24 * 30 * 12 = 31104000
              */
         /**
          * in 1 year, 60 * 60 * 24 * 30 * 12 = 31104000
          */
         case $t < 31104000:
             $text = sprintf(L10n::__('%dm ago'), floor($t / 2592000));
             break;
             /**
              * in 100 year 60 * 60 * 24 * 30 * 12 * 100 = 3110400000
              */
         /**
          * in 100 year 60 * 60 * 24 * 30 * 12 * 100 = 3110400000
          */
         case $t < 3110400000:
             $text = sprintf(L10n::__('%dy ago'), floor($t / 31104000));
             break;
             /**
              * dislay date
              */
         /**
          * dislay date
          */
         default:
             $text = date(L10n::__('M j, Y'), $timestamp);
     }
     return $text;
 }
Example #6
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 
    }
Example #7
0
    protected function tplItemControl($placeholder)
    {
        ?>
        <tr>
            <th><?php 
        echo L10n::__('Control');
        ?>
</th>
            <td>
                <a href="javascript:;" class="button move-up" data-target="<?php 
        echo static::getOptID();
        ?>
item<?php 
        echo $placeholder;
        ?>
" title="<?php 
        echo L10n::__('Move up');
        ?>
"><i class="fa fa-arrow-up"></i></a>

                <a href="javascript:;" class="button move-down" data-target="<?php 
        echo static::getOptID();
        ?>
item<?php 
        echo $placeholder;
        ?>
" title="<?php 
        echo L10n::__('Move down');
        ?>
"><i class="fa fa-arrow-down"></i></a>

                <a href="javascript:;" data-target="<?php 
        echo static::getOptID();
        ?>
item<?php 
        echo $placeholder;
        ?>
" class="del button" title="<?php 
        echo L10n::__('Delete this item');
        ?>
" ><i class="fa fa-trash"></i></a>
            </td>
        </tr>
        <?php 
    }
Example #8
0
    public static function pageOptsList($addonID, $optID)
    {
        static $pages = null;
        if ($pages === null) {
            $pages = \get_pages();
        }
        $opt = Other::getOpts($addonID);
        $selectedPageID = isset($opt[$optID]) ? (int) $opt[$optID] : null;
        ?>
        <select name="<?php 
        echo $addonID;
        ?>
[<?php 
        echo $optID;
        ?>
]" id="<?php 
        echo $addonID;
        ?>
-<?php 
        echo $optID;
        ?>
">
            <option value="-1"><?php 
        echo L10n::__('Select page');
        ?>
</option>
            <?php 
        foreach ($pages as $page) {
            if ($selectedPageID == $page->ID) {
                $selected = ' selected ';
            } else {
                $selected = null;
            }
            ?>
                <option value="<?php 
            echo $page->ID;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo Post::getTheTitle($page->ID);
            ?>
</option>
                <?php 
        }
        ?>
        </select>
        <?php 
    }
Example #9
0
 public static function catOptsList($addonID, $catID, $child = false)
 {
     $opts = (array) Options::getOpts($addonID);
     if ($child !== false) {
         $selectedCatID = isset($opts[$catID][$child]) && $opts[$catID][$child] != 0 ? $opts[$catID][$child] : null;
     } else {
         $selectedCatID = isset($opts[$catID]) && $opts[$catID] != 0 ? $opts[$catID] : null;
     }
     $args = ['name' => $child !== false ? $addonID . '[' . $catID . '][' . $child . ']' : $addonID . '[' . $catID . ']', 'name' => $child !== false ? "{$addonID}[{$catID}][{$child}]" : $addonID . '[' . $catID . ']', 'id' => $child !== false ? $addonID . '-' . $catID . '-' . $child : $addonID . '-' . $catID, 'show_option_none' => L10n::__('Select category'), 'hierarchical' => 1, 'hide_empty' => false, 'selected' => $selectedCatID, 'echo' => 1];
     \wp_dropdown_categories($args);
 }