Plugin Directory

Changeset 1763902


Ignore:
Timestamp:
11/11/2017 05:34:38 PM (8 years ago)
Author:
frankverhoeven
Message:

major restructure

Location:
fv-community-news/trunk
Files:
50 added
12 deleted
14 edited
2 copied
5 moved

Legend:

Unmodified
Added
Removed
  • fv-community-news/trunk/fv-community-news.php

    r1760963 r1763902  
    1010 */
    1111
     12use FvCommunityNews\Application\Application;
     13use FvCommunityNews\Options;
     14use FvCommunityNews\Registry;
     15
    1216if (!defined('ABSPATH')) exit;
    13 
    1417
    1518/**
     
    1821 * @author Frank Verhoeven <[email protected]>
    1922 */
    20 if (!class_exists('FvCommunityNews'))
     23final class FvCommunityNews
    2124{
    22     final class FvCommunityNews
     25    /**
     26     * @var string
     27     */
     28    const VERSION = '3.1';
     29
     30    /**
     31     * __construct()
     32     *
     33     * @version 20120709
     34     */
     35    public function __construct()
     36    {}
     37
     38    /**
     39     * start()
     40     *
     41     * @version 20120710
     42     */
     43    public function start()
    2344    {
    24         /**
    25          * @var string
    26          */
    27         public $version = '3.1';
     45        $this->loadFiles()
     46             ->setupVariables()
     47             ->setupActions();
    2848
    29         /**
    30          * @var FvCommunityNews
    31          */
    32         private static $instance;
     49        $app = new Application();
     50        $app->run();
     51    }
    3352
    34         /**
    35          * __construct()
    36          *
    37          * @version 20120709
    38          */
    39         public function __construct()
    40         {
     53    /**
     54     * setupVariables()
     55     *
     56     * @version 20120710
     57     * @return FvCommunityNews
     58     */
     59    private function setupVariables()
     60    {
     61        $pluginDir = plugin_dir_path(__FILE__);
     62        $pluginUrl = plugin_dir_url(__FILE__);
     63        $baseSlug = Options::fvcnGetOption('_fvcn_base_slug');
    4164
     65        Registry::setInstance(new Registry([
     66            'pluginDir' => $pluginDir,
     67            'pluginUrl' => $pluginUrl,
     68
     69            'themeDir' => $pluginDir . 'fvcn-theme',
     70            'themeUrl' => $pluginUrl . 'fvcn-theme',
     71
     72            'langDir' => $pluginDir . 'fvcn-languages',
     73
     74            'postSlug' => $baseSlug . '/' . Options::fvcnGetOption('_fvcn_post_slug'),
     75            'postTagSlug' => $baseSlug . '/' . Options::fvcnGetOption('_fvcn_post_tag_slug'),
     76            'postArchiveSlug'=> $baseSlug . '/' . Options::fvcnGetOption('_fvcn_post_archive_slug'),
     77        ]));
     78
     79        return $this;
     80    }
     81
     82    /**
     83     * loadFiles()
     84     *
     85     * @version 20120716
     86     * @return FvCommunityNews
     87     * @throws Exception
     88     */
     89    private function loadFiles()
     90    {
     91        include_once __DIR__ . '/src/Autoloader.php';
     92
     93        $autoloader = new \FvCommunityNews\AutoLoader(['FvCommunityNews' => __DIR__ . '/src/']);
     94        $autoloader->register();
     95
     96        $files = [
     97            'fvcn-includes/fvcn-core-hooks.php',
     98            'fvcn-includes/fvcn-core-theme.php',
     99            'fvcn-includes/fvcn-common-functions.php',
     100            'fvcn-includes/fvcn-post-functions.php',
     101
     102            'src/Template/common-functions.php',
     103            'src/Template/options-functions.php',
     104            'src/Template/post-functions.php',
     105            'src/Template/tag-functions.php',
     106            'src/Template/user-functions.php',
     107        ];
     108
     109        $dir = plugin_dir_path(__FILE__);
     110        foreach ($files as $file) {
     111            $autoloader->loadFile($dir . $file);
    42112        }
    43113
    44         /**
    45          * start()
    46          *
    47          * @version 20120710
    48          */
    49         public function start()
    50         {
    51             $this->_loadFiles()
    52                  ->_setupVariables()
    53                  ->_setupActions();
     114        return $this;
     115    }
     116
     117    /**
     118     * setupActions()
     119     *
     120     * @version 20120710
     121     * @return FvCommunityNews
     122     */
     123    private function setupActions()
     124    {
     125        register_activation_hook(__FILE__, 'fvcn_activation');
     126        register_deactivation_hook(__FILE__, 'fvcn_deactivation');
     127
     128        add_action('fvcn_load_text_domain', [$this, 'loadTextdomain'], 5);
     129
     130        return $this;
     131    }
     132
     133    /**
     134     * loadTextdomain()
     135     *
     136     * @version 20120710
     137     * @return bool
     138     */
     139    public function loadTextdomain()
     140    {
     141        $locale = apply_filters('fvcn_locale', get_locale());
     142
     143        $mofile = sprintf('fvcn-%s.mo', $locale);
     144
     145        $mofile_local = Registry::get('langDir') . '/' . $mofile;
     146        $mofile_global = WP_LANG_DIR . '/fv-community-news/' . $mofile;
     147
     148        // /wp-content/plugins/fv-community-news/fvcn-languages/
     149        if (file_exists($mofile_local)) {
     150            return load_textdomain('fvcn', $mofile_local);
     151
     152        // /wp-content/languages/fv-community-news/
     153        } elseif (file_exists($mofile_global)) {
     154            return load_textdomain('fvcn', $mofile_global);
    54155        }
    55156
    56         /**
    57          * _setupVariables()
    58          *
    59          * @version 20120710
    60          * @return FvCommunityNews
    61          */
    62         private function _setupVariables()
    63         {
    64             $pluginDir = plugin_dir_path(__FILE__);
    65             $pluginUrl = plugin_dir_url(__FILE__);
    66             $baseSlug = fvcn_get_option('_fvcn_base_slug');
    67 
    68             FvCommunityNews_Registry::setInstance(new FvCommunityNews_Registry([
    69                 'pluginDir' => $pluginDir,
    70                 'pluginUrl' => $pluginUrl,
    71 
    72                 'themeDir' => $pluginDir . 'fvcn-theme',
    73                 'themeUrl' => $pluginUrl . 'fvcn-theme',
    74 
    75                 'langDir' => $pluginDir . 'fvcn-languages',
    76 
    77                 'postType' => apply_filters('fvcn_post_type', 'fvcn-post'),
    78                 'postTagId' => apply_filters('fvcn_post_tag_id', 'fvcn-tag'),
    79 
    80                 'psPublic' => apply_filters('fvcn_post_status_public', 'publish'),
    81                 'psTrash' => apply_filters('fvcn_post_status_trash', 'trash'),
    82                 'psPrivate' => apply_filters('fvcn_post_status_private', 'private'),
    83                 'psPending' => apply_filters('fvcn_post_status_pending', 'pending'),
    84                 'psSpam' => apply_filters('fvcn_post_status_spam', 'spam'),
    85 
    86                 'postSlug' => apply_filters('fvcn_post_slug', $baseSlug . '/' . fvcn_get_option('_fvcn_post_slug')),
    87                 'postTagSlug' => apply_filters('fvcn_post_tag_slug', $baseSlug . '/' . fvcn_get_option('_fvcn_post_tag_slug')),
    88                 'postArchiveSlug'=>apply_filters('fvcn_post_archive_slug', $baseSlug . '/' . fvcn_get_option('_fvcn_post_archive_slug')),
    89             ]));
    90 
    91             return $this;
    92         }
    93 
    94         /**
    95          * _loadFiles()
    96          *
    97          * @version 20120716
    98          * @return FvCommunityNews
    99          * @throws Exception
    100          */
    101         private function _loadFiles()
    102         {
    103             include_once __DIR__ . '/src/Autoloader.php';
    104 
    105             $autoloader = new \FvCommunityNews\AutoLoader(['FvCommunityNews' => __DIR__ . '/src/']);
    106             $autoloader->register();
    107 
    108             $files = [
    109                 'fvcn-includes/fvcn-core-hooks.php',
    110                 'fvcn-includes/fvcn-core-classes.php',
    111                 'fvcn-includes/fvcn-core-options.php',
    112                 'fvcn-includes/fvcn-core-install.php',
    113                 'fvcn-includes/fvcn-core-javascript.php',
    114                 'fvcn-includes/fvcn-core-validate.php',
    115                 'fvcn-includes/fvcn-core-shortcodes.php',
    116                 'fvcn-includes/fvcn-core-theme.php',
    117                 'fvcn-includes/fvcn-core-sync.php',
    118                 'fvcn-includes/fvcn-common-functions.php',
    119                 'fvcn-includes/fvcn-common-template.php',
    120                 'fvcn-includes/fvcn-post-functions.php',
    121                 'fvcn-includes/fvcn-post-template.php',
    122                 'fvcn-includes/fvcn-tag-template.php',
    123                 'fvcn-includes/fvcn-user-functions.php',
    124                 'fvcn-includes/fvcn-user-template.php',
    125                 'fvcn-includes/fvcn-deprecated-functions.php',
    126                 'fvcn-includes/fvcn-extend-akismet.php'
    127             ];
    128 
    129             if (is_admin()) {
    130                 $files[] = 'fvcn-admin/fvcn-admin.php';
    131             }
    132 
    133             $dir = plugin_dir_path(__FILE__);
    134             foreach ($files as $file) {
    135                 if (file_exists($dir . $file)) {
    136                     require_once $dir . $file;
    137                 } else {
    138                     throw new Exception('The file "' . $file . '" was not found');
    139                 }
    140             }
    141 
    142             return $this;
    143         }
    144 
    145         /**
    146          * _setupActions()
    147          *
    148          * @version 20120710
    149          * @return FvCommunityNews
    150          */
    151         private function _setupActions()
    152         {
    153             register_activation_hook(  __FILE__, 'fvcn_activation');
    154             register_deactivation_hook(__FILE__, 'fvcn_deactivation');
    155 
    156             $actions = [
    157                 'register_post_type' => 'registerPostType',
    158                 'register_post_statuses'=> 'registerPostStatuses',
    159                 'register_taxonomy' => 'registerTaxonomy',
    160                 'load_text_domain' => 'loadTextdomain'
    161             ];
    162 
    163             foreach ($actions as $hook=>$method) {
    164                 add_action('fvcn_' . $hook, [$this, $method], 5);
    165             }
    166 
    167             return $this;
    168         }
    169 
    170         /**
    171          * loadTextdomain()
    172          *
    173          * @version 20120710
    174          * @return bool
    175          */
    176         public function loadTextdomain()
    177         {
    178             $locale = apply_filters('fvcn_locale', get_locale());
    179 
    180             $mofile = sprintf('fvcn-%s.mo', $locale);
    181 
    182             $mofile_local = FvCommunityNews_Registry::get('langDir') . '/' . $mofile;
    183             $mofile_global = WP_LANG_DIR . '/fv-community-news/' . $mofile;
    184 
    185             // /wp-content/plugins/fv-community-news/fvcn-languages/
    186             if (file_exists($mofile_local)) {
    187                 return load_textdomain('fvcn', $mofile_local);
    188 
    189             // /wp-content/languages/fv-community-news/
    190             } elseif (file_exists($mofile_global)) {
    191                 return load_textdomain('fvcn', $mofile_global);
    192             }
    193 
    194             return false;
    195         }
    196 
    197         /**
    198          * registerPostType()
    199          *
    200          * @version 20120710
    201          * @return FvCommunityNews
    202          */
    203         public function registerPostType() {
    204             $post = [
    205                 'labels' => [
    206                     'name' => __('FV Community News', 'fvcn'),
    207                     'menu_name' => __('Community News', 'fvcn'),
    208                     'singular_name' => __('Community News', 'fvcn'),
    209                     'all_items' => __('Community News', 'fvcn'),
    210                     'add_new' => __('New Post', 'fvcn'),
    211                     'add_new_item' => __('Create New Post', 'fvcn'),
    212                     'edit' => __('Edit', 'fvcn'),
    213                     'edit_item' => __('Edit Post', 'fvcn'),
    214                     'new_item' => __('New Post', 'fvcn'),
    215                     'view' => __('View Post', 'fvcn'),
    216                     'view_item' => __('View Post', 'fvcn'),
    217                     'search_items' => __('Search Community News', 'fvcn'),
    218                     'not_found' => __('No posts found', 'fvcn'),
    219                     'not_found_in_trash'=> __('No posts found in Trash','fvcn')
    220                 ],
    221                 'rewrite' => [
    222                     'slug' => FvCommunityNews_Registry::get('postSlug'),
    223                     'with_front' => false
    224                 ],
    225                 'supports' => [
    226                     'title',
    227                     'editor',
    228                     'thumbnail',
    229                     'comments'
    230                 ]
    231             ];
    232 
    233             $options = apply_filters('fvcn_register_fvcn_post_type', [
    234                 'labels' => $post['labels'],
    235                 'rewrite' => $post['rewrite'],
    236                 'supports' => $post['supports'],
    237                 'description' => __('FV Community News Posts', 'fvcn'),
    238                 'has_archive' => FvCommunityNews_Registry::get('postArchiveSlug'),
    239                 'public' => true,
    240                 'publicly_queryable' => true,
    241                 'can_export' => true,
    242                 'hierarchical' => false,
    243                 'query_var' => true,
    244                 'exclude_from_search' => false,
    245                 'show_ui' => true,
    246                 'show_in_menu' => true,
    247                 'menu_position' => 20,
    248                 'menu_icon' => '',
    249                 'capability_type' => 'post',
    250             ]);
    251 
    252             register_post_type(FvCommunityNews_Registry::get('postType'), $options);
    253 
    254             return $this;
    255         }
    256 
    257         /**
    258          * registerPostStatuses()
    259          *
    260          * @version 20120716
    261          * @return FvCommunityNews
    262          */
    263         public function registerPostStatuses() {
    264             $status = apply_filters('fvcn_register_spam_post_status', [
    265                 'label' => __('Spam', 'fvcn'),
    266                 'label_count' => _nx_noop('Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'fvcn'),
    267                 'protected' => true,
    268                 'exclude_from_search' => true,
    269                 'show_in_admin_status_list' => true,
    270                 'show_in_admin_all_list' => false
    271             ]);
    272 
    273             register_post_status(FvCommunityNews_Registry::get('psSpam'), $status);
    274 
    275             return $this;
    276         }
    277 
    278         /**
    279          * registerTaxonomy()
    280          *
    281          * @version 20120716
    282          * @return FvCommunityNews
    283          */
    284         public function registerTaxonomy()
    285         {
    286             $tag = [
    287                 'labels' => [
    288                     'name' => __('Tags', 'fvcn'),
    289                     'singular_name' => __('Tag', 'fvcn'),
    290                     'search_items' => __('Search Tags', 'fvcn'),
    291                     'popular_items' => __('Popular Tags', 'fvcn'),
    292                     'all_items' => __('All Tags', 'fvcn'),
    293                     'edit_item' => __('Edit Tag', 'fvcn'),
    294                     'update_item' => __('Update Tag', 'fvcn'),
    295                     'add_new_item' => __('Add New Tag', 'fvcn'),
    296                     'new_item_name' => __('New Tag Name', 'fvcn'),
    297                 ],
    298                 'rewrite' => [
    299                     'slug' => FvCommunityNews_Registry::get('postTagSlug'),
    300                     'with_front' => false
    301                 ]
    302             ];
    303 
    304             $options = apply_filters('fvcn_register_fvcn_post_tag_id', [
    305                 'labels' => $tag['labels'],
    306                 'rewrite' => $tag['rewrite'],
    307                 'public' => true
    308             ]);
    309 
    310             register_taxonomy(
    311                 FvCommunityNews_Registry::get('postTagId'),
    312                 FvCommunityNews_Registry::get('postType'),
    313                 $options
    314 );
    315 
    316             return $this;
    317         }
    318 
    319 
    320         /**
    321          * setInstance()
    322          *
    323          * @version 20120710
    324          * @param FvCommunityNews $instance
    325          */
    326         public static function setInstance(FvCommunityNews $instance=null)
    327         {
    328             if (null === self::$instance) {
    329                 if (null === $instance) {
    330                     self::$instance = new FvCommunityNews();
    331                 } else {
    332                     self::$instance = $instance;
    333                 }
    334             }
    335         }
    336 
    337         /**
    338          * getInstance()
    339          *
    340          * @version 20120710
    341          * @return FvCommunityNews
    342          */
    343         public static function getInstance()
    344         {
    345             self::setInstance();
    346             return self::$instance;
    347         }
    348     }
    349 
    350 
    351     /**
    352      * Lets roll
    353      *
    354      */
    355     try {
    356         FvCommunityNews::getInstance()->start();
    357     } catch (Exception $e) {
    358         if (defined('WP_DEBUG') && true === WP_DEBUG) {
    359             echo '<h3>' . $e->getMessage() . '</h3><pre>' . $e->getTraceAsString() . '</pre>';
    360         }
    361 
    362         error_log( 'fvcn: ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
     157        return false;
    363158    }
    364159}
    365160
    366161
     162/**
     163 * Lets roll
     164 *
     165 */
     166try {
     167    $fvcn = new FvCommunityNews();
     168    $fvcn->start();
     169} catch (Exception $e) {
     170    if (defined('WP_DEBUG') && true === WP_DEBUG) {
     171        echo '<h3>' . $e->getMessage() . '</h3><pre>' . $e->getTraceAsString() . '</pre>';
     172    }
     173
     174    error_log('fvcn: ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
     175}
    367176
    368177/**
     
    371180 *
    372181 */
    373 
  • fv-community-news/trunk/fvcn-includes/fvcn-common-functions.php

    r1760963 r1763902  
    11<?php
    22
    3 /**
    4  * fvcn-common-functions.php
    5  *
    6  * Common Functions
    7  *
    8  * @package FV Community News
    9  * @subpackage Functions
    10  * @author Frank Verhoeven <[email protected]>
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     exit;
    15 }
    16 
     3use FvCommunityNews\Container;
     4use FvCommunityNews\Options;
     5use FvCommunityNews\Post\PostType;
     6use FvCommunityNews\Registry;
    177
    188/**
     
    2313 * @param string $message
    2414 * @param string $data
    25  * @return void
    2615 */
    2716function fvcn_add_error($code='', $message='', $data='')
    2817{
    29     FvCommunityNews_Container::getInstance()->getWpError()->add($code, $message, $data);
     18    Container::getInstance()->getWpError()->add($code, $message, $data);
    3019}
    3120
     
    4029    $hasErrors = false;
    4130
    42     if (FvCommunityNews_Container::getInstance()->getWpError()->get_error_codes()) {
     31    if (Container::getInstance()->getWpError()->get_error_codes()) {
    4332        $hasErrors = true;
    4433    }
    4534
    46     return apply_filters('fvcn_has_errors', $hasErrors, FvCommunityNews_Container::getInstance()->getWpError());
     35    return apply_filters('fvcn_has_errors', $hasErrors, Container::getInstance()->getWpError());
    4736}
    4837
     
    5140 *
    5241 * @version 20120805
    53  * @return void
    5442 */
    5543function fvcn_add_thumbnail_theme_support()
    5644{
    57     if (true === get_theme_support( 'post-thumbnails')) {
    58         FvCommunityNews_Registry::set('nativeThumbnailSupport', true);
     45    if (true === get_theme_support('post-thumbnails')) {
     46        Registry::set('nativeThumbnailSupport', true);
    5947    } else {
    60         FvCommunityNews_Registry::set('nativeThumbnailSupport', false);
    61         add_theme_support('post-thumbnails', [fvcn_get_post_type(), fvcn_get_post_slug()]);
     48        Registry::set('nativeThumbnailSupport', false);
     49        add_theme_support('post-thumbnails', [PostType::POST_TYPE_KEY, fvcn_get_post_slug()]);
    6250    }
    63 }
    64 
    65 /**
    66  * fvcn_get_public_post_status()
    67  *
    68  * @version 20120710
    69  * @return string
    70  */
    71 function fvcn_get_public_post_status()
    72 {
    73     return FvCommunityNews_Registry::get('psPublic');
    74 }
    75 
    76 /**
    77  * fvcn_get_trash_post_status()
    78  *
    79  * @version 20120710
    80  * @return string
    81  */
    82 function fvcn_get_trash_post_status()
    83 {
    84     return FvCommunityNews_Registry::get('psTrash');
    85 }
    86 
    87 /**
    88  * fvcn_get_private_post_status()
    89  *
    90  * @version 20120710
    91  * @return string
    92  */
    93 function fvcn_get_private_post_status()
    94 {
    95     return FvCommunityNews_Registry::get('psPrivate');
    96 }
    97 
    98 /**
    99  * fvcn_get_pending_post_status()
    100  *
    101  * @version 20120710
    102  * @return string
    103  */
    104 function fvcn_get_pending_post_status()
    105 {
    106     return FvCommunityNews_Registry::get('psPending');
    107 }
    108 
    109 /**
    110  * fvcn_get_spam_post_status()
    111  *
    112  * @version 20120710
    113  * @return string
    114  */
    115 function fvcn_get_spam_post_status()
    116 {
    117     return FvCommunityNews_Registry::get('psSpam');
    11851}
    11952
     
    13164        return $data;
    13265    }
    133     if ($data['post_type'] != fvcn_get_post_type()) {
     66    if ($data['post_type'] != PostType::POST_TYPE_KEY) {
    13467        return $data;
    13568    }
     
    15386{
    15487    if (!fvcn_mail_on_submission() && !fvcn_mail_on_moderation()) {
    155         return;
     88        return false;
    15689    }
    157     if (fvcn_get_spam_post_status() == fvcn_get_post_status($postId)) {
    158         return;
     90    if (PostType::STATUS_SPAM == fvcn_get_post_status($postId)) {
     91        return false;
    15992    }
    16093
    161     if (fvcn_get_pending_post_status() == fvcn_get_post_status($postId) && (fvcn_mail_on_submission() || fvcn_mail_on_moderation())) {
     94    if (PostType::STATUS_PENDING == fvcn_get_post_status($postId) && (fvcn_mail_on_submission() || fvcn_mail_on_moderation())) {
    16295        $subject =    '[' . get_option('blogname') . '] ' . __('New Community Post Awaiting Moderation', 'fvcn');
    163         $moderationPage = add_query_arg(['post_type' => fvcn_get_post_type(), 'post_status' => fvcn_get_pending_post_status()], home_url('/wp-admin/edit.php'));
     96        $moderationPage = add_query_arg(['post_type' => PostType::POST_TYPE_KEY, 'post_status' => PostType::STATUS_PENDING], home_url('/wp-admin/edit.php'));
    16497    } else if (fvcn_mail_on_submission()) {
    16598        $subject =    '[' . get_option('blogname') . '] ' . __('New Community Post', 'fvcn');
    166         $moderationPage = add_query_arg(['post_type' => fvcn_get_post_type()], home_url('/wp-admin/edit.php'));
     99        $moderationPage = add_query_arg(['post_type' => PostType::POST_TYPE_KEY], home_url('/wp-admin/edit.php'));
    167100    } else {
    168         return;
     101        return false;
    169102    }
    170103
    171104    $to = get_option('admin_email');
    172105    if (!is_email($to)) {
    173         return;
     106        return false;
    174107    }
    175108
     
    183116}
    184117
     118
     119///////// Admin Functions
     120
     121/**
     122 * fvcn_form_option()
     123 *
     124 * @version 20120524
     125 * @param string $option
     126 * @param bool $slug
     127 */
     128function fvcn_form_option($option, $slug=false)
     129{
     130    echo fvcn_get_form_option($option, $slug);
     131}
     132
     133/**
     134 * fvcn_get_form_option()
     135 *
     136 * @version 20120524
     137 * @param string $option
     138 * @param bool $slug
     139 * @return mixed
     140 */
     141function fvcn_get_form_option($option, $slug=false)
     142{
     143    $value = Options::fvcnGetOption($option);
     144
     145    if (true === $slug) {
     146        $value = apply_filters('editable_slug', $value);
     147    }
     148
     149    return apply_filters('fvcn_get_form_option', esc_attr($value));
     150}
  • fv-community-news/trunk/fvcn-includes/fvcn-core-hooks.php

    r1760963 r1763902  
    1111 */
    1212
     13use FvCommunityNews\Akismet\Akismet;
     14use FvCommunityNews\Container;
     15use FvCommunityNews\Options;
     16use FvCommunityNews\Post\PostType;
    1317use FvCommunityNews\Widget\Form as FormWidget;
    1418use FvCommunityNews\Widget\ListPosts as ListPostsWidget;
     
    3539 */
    3640add_action('fvcn_init', 'fvcn_load_textdomain', 2);
    37 add_action('fvcn_init', 'fvcn_register_post_type', 10);
    38 add_action('fvcn_init', 'fvcn_register_post_statuses', 12);
    39 add_action('fvcn_init', 'fvcn_register_taxonomy', 14);
    40 add_action('fvcn_init', 'fvcn_register_shortcodes', 16);
    41 add_action('fvcn_init', 'fvcn_javascript', 18);
     41add_action('fvcn_init', [PostType::class, 'register'], 10);
    4242add_action('fvcn_init', 'fvcn_ready', 999);
    43 
    44 
    45 add_action('fvcn_ready', 'fvcn_akismet');
     43add_action('fvcn_init', function() {
     44    add_action('fvcn_enqueue_scripts', [Container::getInstance()->getJavascript(), 'enqueueScripts']);
     45});
     46
     47add_action('fvcn_ready', [Akismet::class, 'fvcn_akismet']);
    4648
    4749
     
    6163 * fvcn_(de)activation
    6264 */
    63 add_action('fvcn_activation', 'fvcn_install');
    6465add_action('fvcn_deactivation', 'flush_rewrite_rules');
    65 add_action('fvcn_uninstall', 'fvcn_delete_options');
    66 
    67 
    68 /**
    69  * fvcn_sync
    70  */
    71 add_action('fvcn_insert_post', 'fvcn_sync_submit_post', 999);
    72 add_action('fvcn_publish_post', 'fvcn_sync_submit_post', 999);
    73 add_action('fvcn_increase_post_view_count', 'fvcn_sync_increase_post_view_count', 999);
    74 add_action('fvcn_post_rating_increase', 'fvcn_sync_increase_post_rating', 999);
    75 add_action('fvcn_post_rating_decrease', 'fvcn_sync_decrease_post_rating', 999);
     66add_action('fvcn_uninstall', [Options::class, 'fvcnDeleteOptions']);
     67
    7668
    7769
     
    157149 */
    158150if (is_admin()) {
    159     add_action('fvcn_init', 'fvcn_admin');
     151    add_action('fvcn_init', function() {
     152        \FvCommunityNews\Container::getInstance()->getAdmin();
     153    });
    160154}
    161155
     
    165159 *
    166160 * @version 20120229
    167  * @return void
    168161 */
    169162function fvcn_activation()
     
    177170 *
    178171 * @version 20120229
    179  * @return void
    180172 */
    181173function fvcn_deactivation()
     
    188180 *
    189181 * @version 20120229
    190  * @return void
    191182 */
    192183function fvcn_uninstall()
     
    199190 *
    200191 * @version 20120229
    201  * @return void
    202192 */
    203193function fvcn_loaded()
     
    210200 *
    211201 * @version 20120229
    212  * @return void
    213202 */
    214203function fvcn_init()
     
    221210 *
    222211 * @version 20120305
    223  * @return void
    224212 */
    225213function fvcn_widgets_init()
     
    232220 *
    233221 * @version 20120229
    234  * @return void
    235222 */
    236223function fvcn_load_textdomain()
     
    243230 *
    244231 * @version 20120229
    245  * @return void
    246232 */
    247233function fvcn_register_post_type()
     
    254240 *
    255241 * @version 20120308
    256  * @return void
    257242 */
    258243function fvcn_register_post_statuses()
     
    265250 *
    266251 * @version 20120229
    267  * @return void
    268252 */
    269253function fvcn_register_taxonomy()
     
    276260 *
    277261 * @version 20120314
    278  * @return void
    279262 */
    280263function fvcn_enqueue_scripts()
     
    287270 *
    288271 * @version 20120229
    289  * @return void
    290272 */
    291273function fvcn_ready()
  • fv-community-news/trunk/fvcn-includes/fvcn-core-theme.php

    r1760963 r1763902  
    11<?php
    22
    3 /**
    4  * fvcn-core-theme.php
    5  *
    6  * Theme
    7  *
    8  * @package FV Community News
    9  * @subpackage Theme
    10  * @author Frank Verhoeven <[email protected]>
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     exit;
    15 }
    16 
    17 
    18 /**
    19  * FvCommunityNews_Theme
    20  *
    21  */
    22 class FvCommunityNews_Theme
    23 {
    24     /**
    25      * @var bool
    26      */
    27     protected $_compatActive = true;
    28 
    29     /**
    30      * __construct()
    31      *
    32      * @version 20120719
    33      * @return void
    34      */
    35     public function __construct()
    36     {
    37 
    38     }
    39 
    40     /**
    41      * isCompatActive()
    42      *
    43      * @version 20120719
    44      * @return bool
    45      */
    46     public function isCompatActive()
    47     {
    48         return $this->_compatActive;
    49     }
    50 }
    51 
     3use FvCommunityNews\Post\PostType;
     4use FvCommunityNews\Registry;
    525
    536/**
     
    5912function fvcn_get_theme_dir()
    6013{
    61     return apply_filters('fvcn_get_theme_dir', FvCommunityNews_Registry::get('themeDir'));
     14    return apply_filters('fvcn_get_theme_dir', Registry::get('themeDir'));
    6215}
    6316
     
    7124function fvcn_get_theme_url()
    7225{
    73     return apply_filters('fvcn_get_theme_url', FvCommunityNews_Registry::get('themeUrl'));
     26    return apply_filters('fvcn_get_theme_url', Registry::get('themeUrl'));
    7427}
    7528
     
    8134 * @param string $slug
    8235 * @param string $name
    83  * @return void
    8436 */
    8537function fvcn_get_template_part($slug, $name=null)
     
    11264
    11365    if ('' == ($template = locate_template($templates))) {
    114         FvCommunityNews_Registry::set('themeCompatActive', true);
    115     } else {
    116         FvCommunityNews_Registry::set('themeCompatActive', false);
     66        Registry::set('themeCompatActive', true);
     67    } else {
     68        Registry::set('themeCompatActive', false);
    11769    }
    11870
     
    13082{
    13183    return fvcn_get_query_template('single_post', [
    132         'single-' . fvcn_get_post_type() . '.php',
     84        'single-' . PostType::POST_TYPE_KEY . '.php',
    13385        'single-fvcn.php'
    13486    ]);
     
    14597{
    14698    return fvcn_get_query_template('post_archive', [
    147         'archive-' . fvcn_get_post_type() . '.php',
     99        'archive-' . PostType::POST_TYPE_KEY . '.php',
    148100        'archive-fvcn.php'
    149101    ]);
     
    170122 *
    171123 * @version 20120717
    172  * @return void
    173124 */
    174125function fvcn_theme_enqueue_css()
     
    194145    $active = true;
    195146
    196     if (false === FvCommunityNews_Registry::get('themeCompatActive')) {
     147    if (false === Registry::get('themeCompatActive')) {
    197148        $active = false;
    198149    }
  • fv-community-news/trunk/fvcn-includes/fvcn-post-functions.php

    r1760963 r1763902  
    11<?php
    22
    3 /**
    4  * fvcn-post-functions.php
    5  *
    6  * Post Functions
    7  *
    8  * @package FV Community News
    9  * @subpackage Functions
    10  * @author Frank Verhoeven <[email protected]>
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     exit;
    15 }
     3use FvCommunityNews\Post\PostType;
     4use FvCommunityNews\Validator\MaxLength;
     5use FvCommunityNews\Validator\MinLength;
     6use FvCommunityNews\Validator\ValidatorChain;
    167
    178/**
     
    3021        'post_title' => '',
    3122        'post_content' => '',
    32         'post_status' => fvcn_get_pending_post_status(),
    33         'post_type' => fvcn_get_post_type(),
     23        'post_status' => PostType::STATUS_PENDING,
     24        'post_type' => PostType::POST_TYPE_KEY,
    3425        'post_password' => '',
    3526        'tax_input' => ''
     
    9182 *
    9283 * @version 20120808
    93  * @return void
    9484 */
    9585function fvcn_new_post_handler()
     
    115105        'post_link' => '',
    116106        'post_tags' => '',
    117         'post_status' => fvcn_get_pending_post_status()
     107        'post_status' => PostType::STATUS_PENDING
    118108    ];
    119     $validator = new FvCommunityNews_Validate();
     109    $validator = new ValidatorChain();
    120110
    121111    // Timeout
    122112    apply_filters('fvcn_post_form_time_key', $validator->setValidators([
    123         'FvCommunityNews_Validate_NotEmpty',
    124         'FvCommunityNews_Validate_Timeout'
     113        'FvCommunityNews\Validator\NotEmpty',
     114        'FvCommunityNews\Validator\Timeout'
    125115    ]));
    126116
     
    132122        // Author Name
    133123        apply_filters('fvcn_post_author_name_validators', $validator->setValidators([
    134             'FvCommunityNews_Validate_NotEmpty',
    135             'FvCommunityNews_Validate_Name',
    136             new FvCommunityNews_Validate_MinLength(2),
    137             new FvCommunityNews_Validate_MaxLength(40)
     124            'FvCommunityNews\Validator\NotEmpty',
     125            'FvCommunityNews\Validator\Name',
     126            new MinLength(2),
     127            new MaxLength(40)
    138128        ]));
    139129
     
    146136        // Author Email
    147137        apply_filters('fvcn_post_author_email_validators', $validator->setValidators([
    148             'FvCommunityNews_Validate_NotEmpty',
    149             'FvCommunityNews_Validate_Email',
    150             new FvCommunityNews_Validate_MinLength(10),
    151             new FvCommunityNews_Validate_MaxLength(60)
     138            'FvCommunityNews\Validator\NotEmpty',
     139            'FvCommunityNews\Validator\Email',
     140            new MinLength(10),
     141            new MaxLength(60)
    152142        ]));
    153143
     
    165155        if (fvcn_user_moderation()) {
    166156            if (fvcn_has_user_posts()) {
    167                 $postData['post_status'] = fvcn_get_public_post_status();
     157                $postData['post_status'] = PostType::STATUS_PUBLISH;
    168158            }
    169159        } else {
    170             $postData['post_status'] = fvcn_get_public_post_status();
     160            $postData['post_status'] = PostType::STATUS_PUBLISH;
    171161        }
    172162    }
     
    174164    // Title
    175165    apply_filters('fvcn_post_title_validators', $validator->setValidators([
    176         'FvCommunityNews_Validate_NotEmpty',
    177         new FvCommunityNews_Validate_MinLength(8),
    178         new FvCommunityNews_Validate_MaxLength(70)
     166        'FvCommunityNews\Validator\NotEmpty',
     167        new MinLength(8),
     168        new MaxLength(70)
    179169    ]));
    180170
     
    188178    if (fvcn_is_post_form_link_required()) {
    189179        apply_filters('fvcn_post_link_validators', $validator->setValidators([
    190             'FvCommunityNews_Validate_NotEmpty',
    191             'FvCommunityNews_Validate_Url',
    192             new FvCommunityNews_Validate_MinLength(6)
     180            'FvCommunityNews\Validator\NotEmpty',
     181            'FvCommunityNews\Validator\Url',
     182            new MinLength(6)
    193183        ]));
    194184
     
    199189        }
    200190    } else {
    201         $validator->setValidators(['FvCommunityNews_Validate_NotEmpty']);
     191        $validator->setValidators(['FvCommunityNews\Validator\NotEmpty']);
    202192
    203193        if ($validator->isValid($_POST['fvcn_post_form_link'])) {
    204194            apply_filters('fvcn_post_link_validators', $validator->setValidators([
    205                 'FvCommunityNews_Validate_Url',
    206                 new FvCommunityNews_Validate_MinLength(6)
     195                'FvCommunityNews\Validator\Url',
     196                new MinLength(6)
    207197            ]));
    208198
     
    220210    // Content
    221211    apply_filters('fvcn_post_content_validators', $validator->setValidators([
    222         'FvCommunityNews_Validate_NotEmpty',
    223         new FvCommunityNews_Validate_MinLength(80)
     212        'FvCommunityNews\Validator\NotEmpty',
     213        new MinLength(80)
    224214    ]));
    225215
     
    233223    if (fvcn_is_post_form_tags_required()) {
    234224        apply_filters('fvcn_post_tags_validators', $validator->setValidators([
    235             'FvCommunityNews_Validate_NotEmpty',
    236             'FvCommunityNews_Validate_Tags',
    237             new FvCommunityNews_Validate_MinLength(2)
     225            'FvCommunityNews\Validator\NotEmpty',
     226            'FvCommunityNews\Validator\Tags',
     227            new MinLength(2)
    238228        ]));
    239229
     
    247237        }
    248238    } else {
    249         $validator->setValidators(['FvCommunityNews_Validate_NotEmpty']);
     239        $validator->setValidators(['FvCommunityNews\Validator\NotEmpty']);
    250240
    251241        if ($validator->isValid($_POST['fvcn_post_form_link'])) {
    252242            apply_filters('fvcn_post_tags_validators', $validator->setValidators([
    253                 'FvCommunityNews_Validate_Tags',
    254                 new FvCommunityNews_Validate_MinLength(2)
     243                'FvCommunityNews\Validator\Tags',
     244                new MinLength(2)
    255245            ]));
    256246
     
    269259    if (fvcn_is_post_form_thumbnail_required()) {
    270260        apply_filters('fvcn_post_title_validators', $validator->setValidators([
    271             'FvCommunityNews_Validate_ImageUpload'
     261            'FvCommunityNews\Validator\ImageUpload'
    272262        ]));
    273263
     
    279269    } else if (!empty($_FILES['fvcn_post_form_thumbnail']['tmp_name'])) {
    280270        apply_filters('fvcn_post_title_validators', $validator->setValidators([
    281             'FvCommunityNews_Validate_ImageUpload'
     271            'FvCommunityNews\Validator\ImageUpload'
    282272        ]));
    283273
     
    300290            'tax_input' => $postData['post_tags'],
    301291            'post_status' => $postData['post_status'],
    302             'post_type' => fvcn_get_post_type()
     292            'post_type' => PostType::POST_TYPE_KEY
    303293        ]);
    304294        $post_meta = apply_filters('fvcn_new_post_meta_pre_insert', [
     
    313303
    314304        if ('template_redirect' == current_filter()) {
    315             if (fvcn_get_public_post_status() == fvcn_get_post_status($postId)) {
    316                 wp_redirect( add_query_arg(['fvcn_added'=>$postId], fvcn_get_post_permalink($postId)));
     305            if (PostType::STATUS_PUBLISH == fvcn_get_post_status($postId)) {
     306                wp_redirect(add_query_arg(['fvcn_added'=>$postId], fvcn_get_post_permalink($postId)));
    317307            } else {
    318                 wp_redirect( add_query_arg(['fvcn_added'=>$postId], home_url('/')));
     308                wp_redirect(add_query_arg(['fvcn_added'=>$postId], home_url('/')));
    319309            }
    320310        } else {
     
    416406 *
    417407 * @version 20120722
    418  * @return void
    419408 */
    420409function fvcn_post_rating_handler()
     
    446435    setcookie('fvcn_post_rated_' . $id . '_' . COOKIEHASH, 'true', time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
    447436
    448     wp_redirect( fvcn_get_post_permalink($id));
     437    wp_redirect(fvcn_get_post_permalink($id));
    449438}
    450439
     
    484473        do_action('fvcn_publish_post', $postId);
    485474
    486         return $this->changePostStatus( $postId, fvcn_get_public_post_status());
     475        return $this->changePostStatus($postId, PostType::STATUS_PUBLISH);
    487476    }
    488477
     
    498487        do_action('fvcn_unpublish_post', $postId);
    499488
    500         return $this->changePostStatus( $postId, fvcn_get_pending_post_status());
     489        return $this->changePostStatus($postId, PostType::STATUS_PENDING);
    501490    }
    502491
     
    512501        do_action('fvcn_spam_post', $postId);
    513502
    514         return $this->changePostStatus( $postId, fvcn_get_spam_post_status());
     503        return $this->changePostStatus($postId, PostType::STATUS_SPAM);
    515504    }
    516505
     
    520509     * @version 20120722
    521510     * @param int $postId
    522      * @return void
    523      */
     511         */
    524512    public function increasePostRating($postId)
    525513    {
     
    534522     * @version 20120722
    535523     * @param int $postId
    536      * @return void
    537      */
     524         */
    538525    public function decreasePostRating($postId)
    539526    {
     
    548535     * @version 20120724
    549536     * @param int $postId
    550      * @return void
    551      */
     537         */
    552538    public function increasePostViewCount($postId)
    553539    {
     
    557543    }
    558544}
    559 
  • fv-community-news/trunk/fvcn-theme/archive-fvcn.php

    r1760963 r1763902  
    2020        </header>
    2121
    22         <?php twentyeleven_content_nav( 'nav-above'); ?>
     22        <?php twentyeleven_content_nav('nav-above'); ?>
    2323
    2424        <?php while (have_posts()) : the_post(); ?>
     
    5050        <?php endwhile; ?>
    5151
    52         <?php twentyeleven_content_nav( 'nav-below'); ?>
     52        <?php twentyeleven_content_nav('nav-below'); ?>
    5353
    5454    <?php else : ?>
  • fv-community-news/trunk/fvcn-theme/fvcn/css/fvcn-theme.css

    r1760963 r1763902  
    1 @charset "UTF-8";
    2 
    31/**
    42 * FV Community News Styles
    53 *
    6  * @version    20120716
    7  * @author    Frank Verhoeven <[email protected]>
     4 * @author Frank Verhoeven <[email protected]>
     5 * @version 20171111
    86 */
    97
     
    4543 */
    4644.fvcn-template-notice {
    47     border-width: 1px;
    48     border-style: solid;
    4945    padding: .1em .4em;
    5046    margin: 5px 0 !important;
    5147    border-radius: 4px;
    5248    background-color: #ffffe0;
    53     border-color: #e6db55;
     49    border: 1px solid #e6db55;
    5450    color: #000;
    5551    clear: both;
     
    9894
    9995.fvcn-post-form-ajax-loader .fvcn-post-form-ajax-progress-bar-inner {
    100     width: 0%;
     96    width: 0;
    10197    padding: 0 !important;
    10298    height: 4px !important;
     
    111107    width: 100%;
    112108}
    113 
    114 
    115 
    116 
    117 
    118 
    119 
    120 
    121 
    122 
    123 
    124 
  • fv-community-news/trunk/public/js/fvcn-js.js

    r1763901 r1763902  
    4343                }
    4444
    45                 $('.fvcn-post-form-ajax-progress-bar-inner').width( percentComplete + '%');
     45                $('.fvcn-post-form-ajax-progress-bar-inner').width(percentComplete + '%');
    4646            },
    4747            success: function(response) {
  • fv-community-news/trunk/src/Application/Application.php

    r1760963 r1763902  
    55class Application
    66{
    7 
     7    public function run()
     8    {
     9        $bootstrap = new Bootstrap();
     10        $bootstrap->registerShortcodes();
     11    }
    812}
  • fv-community-news/trunk/src/Application/Bootstrap.php

    r1760963 r1763902  
    22
    33namespace FvCommunityNews\Application;
     4
     5use FvCommunityNews;
     6use FvCommunityNews\Admin\Admin;
     7use FvCommunityNews\Admin\AdminFactory;
     8use FvCommunityNews\Container;
     9use FvCommunityNews\Installer;
     10use FvCommunityNews\Post\PostType;
    411
    512/**
     
    1017class Bootstrap
    1118{
     19    public function registerHooks()
     20    {
     21        add_action('fvcn_activation', [$this, 'installation']);
     22        add_action('fvcn_init', [$this, 'registerShortcodes'], 16);
    1223
     24    }
     25
     26    public function installation()
     27    {
     28        $installer = new Installer(Container::getInstance()->getOptions());
     29
     30        $installer->hasUpdate();
     31
     32        if ($installer->isInstall()) {
     33            $installer->install();
     34        } elseif ($installer->isUpdate()) {
     35            $installer->update();
     36        }
     37
     38        PostType::register();
     39
     40        flush_rewrite_rules();
     41    }
     42
     43    public function registerShortcodes()
     44    {
     45        Container::getInstance()->getShortcodes();
     46    }
    1347}
  • fv-community-news/trunk/src/Options.php

    r1760963 r1763902  
    1010class Options
    1111{
     12    /**
     13     * @var array
     14     */
     15    private $options;
    1216    /**
    1317     * @var array
    1418     */
    15     protected $defaultOptions = [];
    16 
    17     /**
    18      * @var array
    19      */
    20     protected $options = [];
     19    private $defaults;
    2120
    2221    /**
    2322     * __construct()
    2423     *
    25      * @version 20171103
    26      */
    27     public function __construct()
    28     {
    29         $this->setDefaultOptions();
    30     }
    31 
    32     /**
    33      * setDefaultOptions()
    34      *
    35      * @return $this
    36      * @version 20171103
    37      */
    38     protected function setDefaultOptions()
    39     {
    40         $this->defaultOptions = [];
    41 
    42         return $this;
    43     }
     24     * @param array $defaults
     25     * @version 20171111
     26     */
     27    public function __construct(array $defaults)
     28    {
     29        $this->options = [];
     30        $this->defaults = apply_filters('fvcn_set_default_options', $defaults);
     31    }
    4432
    4533    /**
     
    5139    public function getDefaultOptions()
    5240    {
    53         return $this->defaultOptions;
     41        return $this->defaults;
    5442    }
    5543
     
    6351    public function getDefaultOption($key)
    6452    {
    65         if (!isset($this->defaultOptions[ $key ])) {
     53        if (!isset($this->defaults[ $key ])) {
    6654            return null;
    6755        }
    6856
    69         return $this->defaultOptions[ $key ];
     57        return $this->defaults[ $key ];
    7058    }
    7159
     
    7866    public function addOptions()
    7967    {
    80         foreach ($this->getDefaultOptions() as $key=>$value) {
     68        foreach ($this->getDefaultOptions() as $key => $value) {
    8169            $this->addOption($key, $value);
    8270        }
     
    125113     * @version 20171103
    126114     */
    127     public function getOption($key, $default=null)
     115    public function getOption($key, $default = null)
    128116    {
    129117        if (isset($this->options[ $key ])) {
    130118            return $this->options[ $key ];
    131119        }
    132 
    133120        if (null === $default) {
    134121            return $this->options[ $key ] = get_option($key, $this->getDefaultOption($key));
     
    146133    public function deleteOptions()
    147134    {
    148         foreach ($this->getDefaultOptions() as $key=>$value) {
     135        foreach ($this->getDefaultOptions() as $key => $value) {
    149136            $this->deleteOption($key);
    150137        }
     
    167154        return $this;
    168155    }
     156
     157
     158    /**
     159     * fvcnGetDefaultOptions()
     160     *
     161     * @version 20120710
     162     * @return array
     163     */
     164    public static function fvcnGetDefaultOptions()
     165    {
     166        return Container::getInstance()->getOptions()->getDefaultOptions();
     167    }
     168
     169    /**
     170     * fvcnGetDefaultOption()
     171     *
     172     * @version 20120710
     173     * @param string $key
     174     * @return mixed
     175     */
     176    public static function fvcnGetDefaultOption($key)
     177    {
     178        return Container::getInstance()->getOptions()->getDefaultOption($key);
     179    }
     180
     181    /**
     182     * fvcnGetOption()
     183     *
     184     * @version 20120710
     185     * @param string $key
     186     * @return mixed
     187     */
     188    public static function fvcnGetOption($key)
     189    {
     190        return Container::getInstance()->getOptions()->getOption($key);
     191    }
     192
     193    /**
     194     * fvcnAddOptions()
     195     *
     196     * @version 20120710
     197     */
     198    public static function fvcnAddOptions()
     199    {
     200        Container::getInstance()->getOptions()->addOptions();
     201
     202        do_action('fvcn_add_options');
     203    }
     204
     205    /**
     206     * fvcnDeleteOptions()
     207     *
     208     * @version 20120710
     209     */
     210    public static function fvcnDeleteOptions()
     211    {
     212        Container::getInstance()->getOptions()->deleteOptions();
     213
     214        do_action('fvcn_delete_options');
     215    }
    169216}
  • fv-community-news/trunk/src/Template/common-functions.php

    r1763901 r1763902  
    11<?php
    22
    3 /**
    4  * fvcn-common-template.php
    5  *
    6  * Common Template
    7  *
    8  * @package    FV Community News
    9  * @subpackage Template
    10  * @author Frank Verhoeven
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     die('Direct access is not allowed!');
    15 }
    16 
     3use FvCommunityNews\Container;
     4use FvCommunityNews\Registry;
    175
    186/**
     
    208 *
    219 * @version 20120322
    22  * @uses fvcn_get_version()
    23  * @return void
    2410 */
    2511function fvcn_version()
     
    3521    function fvcn_get_version()
    3622    {
    37         return fvcn_get_option('_fvcn_version');
     23        return \FvCommunityNews\Options::fvcnGetOption('_fvcn_version');
    3824    }
    3925
     
    4127 * fvcn_head()
    4228 *
    43  * @version 20120314
    44  * @uses do_action()
    45  * @return void
     29 * @version 20171111
    4630 */
    4731function fvcn_head()
    4832{
    49     echo '<meta name="generator" content="FV Community News" />' . "\n";
    50 
     33    echo '<meta name="generator" content="FV Community News">' . "\n";
    5134    do_action('fvcn_head');
    52 
    5335}
    5436
     
    5739 *
    5840 * @version 20120713
    59  * @uses fvcn_has_errors()
    60  * @uses $fvcn->errors
    61  * @return void
    6241 */
    6342function fvcn_template_notices()
     
    6948    $errors = $messages = [];
    7049
    71     foreach (FvCommunityNews_Container::getInstance()->getWpError()->get_error_codes() as $code) {
    72         $severity = FvCommunityNews_Container::getInstance()->getWpError()->get_error_data($code);
     50    foreach (Container::getInstance()->getWpError()->get_error_codes() as $code) {
     51        $severity = Container::getInstance()->getWpError()->get_error_data($code);
    7352
    74         foreach (FvCommunityNews_Container::getInstance()->getWpError()->get_error_messages($code) as $error) {
     53        foreach (Container::getInstance()->getWpError()->get_error_messages($code) as $error) {
    7554            if ('message' == $severity) {
    7655                $messages[] = $error;
     
    10180
    10281/**
    103  * is_FvCommunityNews::getInstance()
     82 * is_fvcn()
    10483 *
    10584 * @version 20120622
     
    129108function fvcn_show_widget_thumbnail()
    130109{
    131     return FvCommunityNews_Registry::getInstance()->widgetShowThumbnail;
     110    return Registry::getInstance()->widgetShowThumbnail;
    132111}
    133112
     
    140119function fvcn_show_widget_view_all()
    141120{
    142     return FvCommunityNews_Registry::getInstance()->widgetShowViewAll;
     121    return Registry::getInstance()->widgetShowViewAll;
    143122}
    144 
  • fv-community-news/trunk/src/Template/options-functions.php

    r1763901 r1763902  
    11<?php
    22
    3 /**
    4  * fvcn-core-options.php
    5  *
    6  * Options
    7  *
    8  * @package    FV Community News
    9  * @subpackage Options
    10  * @author Frank Verhoeven
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     die('Direct access is not allowed!');
    15 }
    16 
    17 
    18 class FvCommunityNews_Options
    19 {
    20     /**
    21      * @var array
    22      */
    23     protected $_defaultOptions = [];
    24 
    25     /**
    26      * @var array
    27      */
    28     protected $_options = [];
    29 
    30     /**
    31      * __construct()
    32      *
    33      * @version 20120710
    34      * @return void
    35      */
    36     public function __construct()
    37     {
    38         $this->_setDefaultOptions();
    39     }
    40 
    41     /**
    42      * _setDefaultOptions()
    43      *
    44      * @version 20120710
    45      * @return FvCommunityNews_Options
    46      */
    47     protected function _setDefaultOptions()
    48     {
    49         $this->_defaultOptions = apply_filters('fvcn_get_default_options', [
    50             '_fvcn_version' => FvCommunityNews::getInstance()->version,
    51 
    52             '_fvcn_admin_moderation' => false,
    53             '_fvcn_user_moderation' => true,
    54             '_fvcn_mail_on_submission' => false,
    55             '_fvcn_mail_on_moderation' => true,
    56             '_fvcn_is_anonymous_allowed' => true,
    57 
    58             '_fvcn_base_slug' => 'fv-community-news',
    59             '_fvcn_post_slug' => 'post',
    60             '_fvcn_post_tag_slug' => 'tag',
    61             '_fvcn_post_archive_slug' => 'archive',
    62 
    63             '_fvcn_post_form_author_name_label' => __('Author Name', 'fvcn'),
    64             '_fvcn_post_form_author_email_label' => __('Author Email', 'fvcn'),
    65             '_fvcn_post_form_title_label' => __('Title', 'fvcn'),
    66             '_fvcn_post_form_link_label' => __('Link', 'fvcn'),
    67             '_fvcn_post_form_link_required' => true,
    68             '_fvcn_post_form_content_label' => __('Description', 'fvcn'),
    69             '_fvcn_post_form_tags_label' => __('Tags', 'fvcn'),
    70             '_fvcn_post_form_tags_required' => true,
    71             '_fvcn_post_form_thumbnail_enabled' => true,
    72             '_fvcn_post_form_thumbnail_label' => __('Thumbnail', 'fvcn'),
    73             '_fvcn_post_form_thumbnail_required' => false,
    74 
    75             '_fvcn_sync_key' => false,
    76 
    77             '_fvcn_dashboard_rp_num' => 5
    78         ]);
    79 
    80         return $this;
    81     }
    82 
    83     /**
    84      * getDefaultOptions()
    85      *
    86      * @version 20120710
    87      * @return array
    88      */
    89     public function getDefaultOptions()
    90     {
    91         return $this->_defaultOptions;
    92     }
    93 
    94     /**
    95      * getDefaultOption()
    96      *
    97      * @version 20120716
    98      * @param string $key
    99      * @return mixed
    100      */
    101     public function getDefaultOption($key)
    102     {
    103         if (!isset($this->_defaultOptions[ $key ])) {
    104             return null;
    105         }
    106 
    107         return $this->_defaultOptions[ $key ];
    108     }
    109 
    110     /**
    111      * addOptions()
    112      *
    113      * @version 20120710
    114      * @return FvCommunityNews_Options
    115      */
    116     public function addOptions()
    117     {
    118         foreach ($this->getDefaultOptions() as $key=>$value) {
    119             $this->addOption($key, $value);
    120         }
    121 
    122         return $this;
    123     }
    124 
    125     /**
    126      * addOption()
    127      *
    128      * @version 20120710
    129      * @param string $key
    130      * @param mixed $value
    131      * @return FvCommunityNews_Options
    132      */
    133     public function addOption($key, $value)
    134     {
    135         add_option($key, $value);
    136         $this->_options[ $key ] = $value;
    137 
    138         return $this;
    139     }
    140 
    141     /**
    142      * updateOption()
    143      *
    144      * @version 20120716
    145      * @param string $key
    146      * @param mixed $value
    147      * @return FvCommunityNews_Options
    148      */
    149     public function updateOption($key, $value)
    150     {
    151         update_option($key, $value);
    152         $this->_options[ $key ] = $value;
    153 
    154         return $this;
    155     }
    156 
    157     /**
    158      * getOption()
    159      *
    160      * @version 20120716
    161      * @param string $key
    162      * @param mixed $default
    163      * @return mixed
    164      */
    165     public function getOption($key, $default=null)
    166     {
    167         if (isset($this->_options[ $key ])) {
    168             return $this->_options[ $key ];
    169         }
    170 
    171         if (null === $default) {
    172             return $this->_options[ $key ] = get_option($key, $this->getDefaultOption($key));
    173         }
    174 
    175         return $this->_options[ $key ] = get_option($key, $default);
    176     }
    177 
    178     /**
    179      * deleteOptions()
    180      *
    181      * @version 20120710
    182      * @return FvCommunityNews_Options
    183      */
    184     public function deleteOptions()
    185     {
    186         foreach ($this->getDefaultOptions() as $key=>$value) {
    187             $this->deleteOption($key);
    188         }
    189 
    190         return $this;
    191     }
    192 
    193     /**
    194      * deleteOption()
    195      *
    196      * @version 20120710
    197      * @param string $key
    198      * @return FvCommunityNews_Options
    199      */
    200     public function deleteOption($key)
    201     {
    202         delete_option($key);
    203         unset($this->_options[ $key ]);
    204 
    205         return $this;
    206     }
    207 }
    208 
    209 
    210 
    211 /**
    212  * fvcn_get_default_options()
    213  *
    214  * @version 20120710
    215  * @return array
    216  */
    217 function fvcn_get_default_options()
    218 {
    219     return FvCommunityNews_Container::getInstance()->getOptions()->getDefaultOptions();
    220 }
    221 
    222 /**
    223  * fvcn_get_default_option()
    224  *
    225  * @version 20120710
    226  * @param string $key
    227  * @return mixed
    228  */
    229 function fvcn_get_default_option($key)
    230 {
    231     return FvCommunityNews_Container::getInstance()->getOptions()->getDefaultOption($key);
    232 }
    233 
    234 /**
    235  * fvcn_get_option()
    236  *
    237  * @version 20120710
    238  * @param string $key
    239  * @return mixed
    240  */
    241 function fvcn_get_option($key)
    242 {
    243     return FvCommunityNews_Container::getInstance()->getOptions()->getOption($key);
    244 }
    245 
    246 /**
    247  * fvcn_add_options()
    248  *
    249  * @version 20120710
    250  * @return void
    251  */
    252 function fvcn_add_options()
    253 {
    254     FvCommunityNews_Container::getInstance()->getOptions()->addOptions();
    255 
    256     do_action('fvcn_add_options');
    257 }
    258 
    259 /**
    260  * fvcn_delete_options()
    261  *
    262  * @version 20120710
    263  * @return void
    264  */
    265 function fvcn_delete_options()
    266 {
    267     FvCommunityNews_Container::getInstance()->getOptions()->deleteOptions();
    268 
    269     do_action('fvcn_delete_options');
    270 }
    271 
     3use FvCommunityNews\Options;
    2724
    2735/**
    2746 * fvcn_admin_moderation()
    2757 *
     8 * @return bool
    2769 * @version 20120524
    277  * @uses fvcn_get_option()
    278  * @uses apply_filters()
    279  * @return bool
    28010 */
    28111function fvcn_admin_moderation()
    28212{
    283     return apply_filters('fvcn_admin_moderation', (bool) fvcn_get_option('_fvcn_admin_moderation'));
     13    return apply_filters('fvcn_admin_moderation', (bool) Options::fvcnGetOption('_fvcn_admin_moderation'));
    28414}
    285 
    28615
    28716/**
    28817 * fvcn_user_moderation()
    28918 *
     19 * @return bool
    29020 * @version 20120524
    291  * @uses fvcn_get_option()
    292  * @uses apply_filters()
    293  * @return bool
    29421 */
    29522function fvcn_user_moderation()
    29623{
    297     return apply_filters('fvcn_user_moderation', (bool) fvcn_get_option('_fvcn_user_moderation'));
     24    return apply_filters('fvcn_user_moderation', (bool) Options::fvcnGetOption('_fvcn_user_moderation'));
    29825}
    299 
    30026
    30127/**
    30228 * fvcn_mail_on_submission()
    30329 *
     30 * @return bool
    30431 * @version 20120524
    305  * @uses fvcn_get_option()
    306  * @uses apply_filters()
    307  * @return bool
    30832 */
    30933function fvcn_mail_on_submission()
    31034{
    311     return apply_filters('fvcn_mail_on_submission', (bool) fvcn_get_option('_fvcn_mail_on_submission'));
     35    return apply_filters('fvcn_mail_on_submission', (bool) Options::fvcnGetOption('_fvcn_mail_on_submission'));
    31236}
    313 
    31437
    31538/**
    31639 * fvcn_mail_on_moderation()
    31740 *
     41 * @return bool
    31842 * @version 20120524
    319  * @uses fvcn_get_option()
    320  * @uses apply_filters()
    321  * @return bool
    32243 */
    32344function fvcn_mail_on_moderation()
    32445{
    325     return apply_filters('fvcn_mail_on_moderation', (bool) fvcn_get_option('_fvcn_mail_on_moderation'));
     46    return apply_filters('fvcn_mail_on_moderation', (bool) Options::fvcnGetOption('_fvcn_mail_on_moderation'));
    32647}
    327 
    32848
    32949/**
    33050 * fvcn_is_anonymous_allowed()
    33151 *
     52 * @return bool
    33253 * @version 20120524
    333  * @uses fvcn_get_option()
    334  * @uses apply_filters()
    335  * @return bool
    33654 */
    33755function fvcn_is_anonymous_allowed()
    33856{
    339     return apply_filters('fvcn_is_anonymous_allowed', (bool) fvcn_get_option('_fvcn_is_anonymous_allowed'));
     57    return apply_filters('fvcn_is_anonymous_allowed', (bool) Options::fvcnGetOption('_fvcn_is_anonymous_allowed'));
    34058}
    341 
  • fv-community-news/trunk/src/Template/post-functions.php

    r1763901 r1763902  
    11<?php
    22
    3 /**
    4  * fvcn-post-template.php
    5  *
    6  * Post Template
    7  *
    8  * @package FV Community News
    9  * @subpackage Template
    10  * @author Frank Verhoeven
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     exit;
    15 }
    16 
    17 /**
    18  * fvcn_post_type()
    19  *
    20  * @version 20120229
    21  * @return void
    22  */
    23 function fvcn_post_type()
    24 {
    25     echo fvcn_get_post_type();
    26 }
    27 
    28     /**
    29      * fvcn_get_post_type()
    30      *
    31      * @version 20120229
    32      * @return string
    33      */
    34     function fvcn_get_post_type()
    35     {
    36         return apply_filters('fvcn_get_post_type', FvCommunityNews_Registry::get('postType'));
    37     }
     3use FvCommunityNews\Container;
     4use FvCommunityNews\Options;
     5use FvCommunityNews\Post\PostType;
     6use FvCommunityNews\Registry;
    387
    398
     
    4211 *
    4312 * @version 20120321
    44  * @return void
    4513 */
    4614function fvcn_post_slug()
     
    5725    function fvcn_get_post_slug()
    5826    {
    59         return apply_filters('fvcn_get_post_slug', FvCommunityNews_Registry::get('postSlug'));
     27        return apply_filters('fvcn_get_post_slug', Registry::get('postSlug'));
    6028    }
    6129
     
    7139{
    7240    $defaults = [
    73         'post_type' => fvcn_get_post_type(),
    74         'post_status' => fvcn_get_public_post_status(),
     41        'post_type' => PostType::POST_TYPE_KEY,
     42        'post_status' => PostType::STATUS_PUBLISH,
    7543        'posts_per_page'=> 15,
    7644        'order' => 'DESC'
     
    8048    $options = apply_filters('fvcn_has_posts_query', $options);
    8149
    82     FvCommunityNews_Registry::set('wpQuery', new WP_Query( $options));
    83 
    84     return apply_filters('fvcn_has_posts', FvCommunityNews_Registry::get('wpQuery')->have_posts(), FvCommunityNews_Registry::get('wpQuery'));
     50    Registry::set('wpQuery', new WP_Query($options));
     51
     52    return apply_filters('fvcn_has_posts', Registry::get('wpQuery')->have_posts(), Registry::get('wpQuery'));
    8553}
    8654
     
    9462function fvcn_posts()
    9563{
    96     $have_posts = FvCommunityNews_Registry::get('wpQuery')->have_posts();
     64    $have_posts = Registry::get('wpQuery')->have_posts();
    9765
    9866    if (empty($have_posts)) {
     
    11280function fvcn_the_post()
    11381{
    114     return FvCommunityNews_Registry::get('wpQuery')->the_post();
     82    return Registry::get('wpQuery')->the_post();
    11583}
    11684
     
    12189 * @version 20120305
    12290 * @param int $postId
    123  * @return void
    124  */
    125 function fvcn_post_id($postId=0)
     91 */
     92function fvcn_post_id($postId = 0)
    12693{
    12794    echo fvcn_get_post_id($postId);
     
    135102     * @return int
    136103     */
    137     function fvcn_get_post_id($postId=0)
     104    function fvcn_get_post_id($postId = 0)
    138105    {
    139106        global $wp_query, $post;
     
    142109            $id = $postId;
    143110
    144         } elseif (!empty(FvCommunityNews_Registry::get('wpQuery')->in_the_loop) && isset(FvCommunityNews_Registry::get('wpQuery')->post->ID)) {
    145             $id = FvCommunityNews_Registry::get('wpQuery')->post->ID;
     111        } elseif (!empty(Registry::get('wpQuery')->in_the_loop) && isset(Registry::get('wpQuery')->post->ID)) {
     112            $id = Registry::get('wpQuery')->post->ID;
    146113
    147114        } elseif (fvcn_is_single_post() && isset($wp_query->post->ID)) {
     
    166133 * @return object
    167134 */
    168 function fvcn_get_post($postId=0)
     135function fvcn_get_post($postId = 0)
    169136{
    170137    $id = fvcn_get_post_id($postId);
     
    176143    $post = get_post($id, OBJECT);
    177144
    178     if (!$post || $post->post_type != fvcn_get_post_type()) {
     145    if (!$post || $post->post_type != PostType::POST_TYPE_KEY) {
    179146        return null;
    180147    }
     
    189156 * @version 20120305
    190157 * @param int $postId
    191  * @return void
    192  */
    193 function fvcn_post_permalink($postId=0)
     158 */
     159function fvcn_post_permalink($postId = 0)
    194160{
    195161    echo fvcn_get_post_permalink($postId);
     
    204170     * @return string
    205171     */
    206     function fvcn_get_post_permalink($postId=0, $redirect='')
     172    function fvcn_get_post_permalink($postId = 0, $redirect='')
    207173    {
    208174        $id = fvcn_get_post_id($postId);
     
    225191 * @return bool
    226192 */
    227 function fvcn_has_post_link($postId=0)
     193function fvcn_has_post_link($postId = 0)
    228194{
    229195    $link = fvcn_get_post_link($postId);
     
    238204 * @version 20120311
    239205 * @param int $postId
    240  * @return void
    241  */
    242 function fvcn_post_link($postId=0)
     206 */
     207function fvcn_post_link($postId = 0)
    243208{
    244209    echo fvcn_get_post_link($postId);
     
    252217     * @return string
    253218     */
    254     function fvcn_get_post_link($postId=0)
    255     {
    256         $id = fvcn_get_post_id($postId);
    257 
    258         $link = esc_url( get_post_meta($id, '_fvcn_post_url', true));
     219    function fvcn_get_post_link($postId = 0)
     220    {
     221        $id = fvcn_get_post_id($postId);
     222
     223        $link = esc_url(get_post_meta($id, '_fvcn_post_url', true));
    259224
    260225        return apply_filters('fvcn_get_post_link', $link, $id);
     
    267232 * @version 20120305
    268233 * @param int $postId
    269  * @return void
    270  */
    271 function fvcn_post_title($postId=0)
     234 */
     235function fvcn_post_title($postId = 0)
    272236{
    273237    echo fvcn_get_post_title($postId);
     
    281245     * @return string
    282246     */
    283     function fvcn_get_post_title($postId=0)
     247    function fvcn_get_post_title($postId = 0)
    284248    {
    285249        $id = fvcn_get_post_id($postId);
     
    294258 * @version 20120305
    295259 * @param int $postId
    296  * @return void
    297  */
    298 function fvcn_post_content($postId=0)
     260 */
     261function fvcn_post_content($postId = 0)
    299262{
    300263    echo fvcn_get_post_content($postId);
     
    308271     * @return string
    309272     */
    310     function fvcn_get_post_content($postId=0)
     273    function fvcn_get_post_content($postId = 0)
    311274    {
    312275        $id = fvcn_get_post_id($postId);
     
    328291 * @param int $postId
    329292 * @param int $length
    330  * @return void
    331  */
    332 function fvcn_post_excerpt($postId=0, $length=100) {
     293 */
     294function fvcn_post_excerpt($postId = 0, $length=100) {
    333295    echo fvcn_get_post_excerpt($postId, $length);
    334296}
     
    342304     * @return string
    343305     */
    344     function fvcn_get_post_excerpt($postId=0, $length=100) {
     306    function fvcn_get_post_excerpt($postId = 0, $length=100) {
    345307        $id = fvcn_get_post_id($postId);
    346308        $length = abs((int)$length);
     
    356318        }
    357319
    358         $excerpt = trim( strip_tags($excerpt));
     320        $excerpt = trim(strip_tags($excerpt));
    359321
    360322        if (!empty($length) && strlen($excerpt) > $length) {
     
    382344 * @param int $postId
    383345 * @param string $format
    384  * @return void
    385  */
    386 function fvcn_post_date($postId=0, $format='') {
     346 */
     347function fvcn_post_date($postId = 0, $format='') {
    387348    echo fvcn_get_post_date($postId, $format);
    388349}
     
    396357     * @return string
    397358     */
    398     function fvcn_get_post_date($postId=0, $format='') {
     359    function fvcn_get_post_date($postId = 0, $format='') {
    399360        $id = fvcn_get_post_id($postId);
    400361
     
    416377 * @param string $format
    417378 * @param bool $gmt
    418  * @return void
    419  */
    420 function fvcn_post_time($postId=0, $format='', $gmt=false) {
     379 */
     380function fvcn_post_time($postId = 0, $format='', $gmt=false) {
    421381    echo fvcn_get_post_time($postId, $format, $gmt);
    422382}
     
    431391     * @return string
    432392     */
    433     function fvcn_get_post_time($postId=0, $format='', $gmt=false) {
     393    function fvcn_get_post_time($postId = 0, $format='', $gmt=false) {
    434394        $id = fvcn_get_post_id($postId);
    435395
     
    457417 * @return bool
    458418 */
    459 function fvcn_has_post_thumbnail($postId=0)
     419function fvcn_has_post_thumbnail($postId = 0)
    460420{
    461421    $id = fvcn_get_post_id($postId);
    462422
    463423    // Double thumbnail display fix.
    464     if ('the_content' != current_filter() || false === FvCommunityNews_Registry::get('nativeThumbnailSupport')) {
     424    if ('the_content' != current_filter() || false === Registry::get('nativeThumbnailSupport')) {
    465425        return has_post_thumbnail($id);
    466426    } else {
     
    477437 * @param string|array $size
    478438 * @param string|array $attributes
    479  * @return void
    480  */
    481 function fvcn_post_thumbnail($postId=0, $size='thumbnail', $attributes= []) {
     439 */
     440function fvcn_post_thumbnail($postId = 0, $size='thumbnail', $attributes= []) {
    482441    echo fvcn_get_post_thumbnail($postId, $size, $attributes);
    483442}
     
    492451     * @return string
    493452     */
    494     function fvcn_get_post_thumbnail($postId=0, $size='thumbnail', $attributes= []) {
     453    function fvcn_get_post_thumbnail($postId = 0, $size='thumbnail', $attributes= []) {
    495454        $id = fvcn_get_post_id($postId);
    496455
     
    504463 * @version 20120321
    505464 * @param int $postId
    506  * @return void
    507  */
    508 function fvcn_post_rating($postId=0)
     465 */
     466function fvcn_post_rating($postId = 0)
    509467{
    510468    echo fvcn_get_post_rating($postId);
     
    518476     * @return string
    519477     */
    520     function fvcn_get_post_rating($postId=0)
     478    function fvcn_get_post_rating($postId = 0)
    521479    {
    522480        $id = fvcn_get_post_id($postId);
     
    537495 * @version 20120321
    538496 * @param int $postId
    539  * @return void
    540  */
    541 function fvcn_post_rating_increment_link($postId=0)
     497 */
     498function fvcn_post_rating_increment_link($postId = 0)
    542499{
    543500    echo fvcn_get_post_rating_increment_link($postId);
     
    551508     * @return string
    552509     */
    553     function fvcn_get_post_rating_increment_link($postId=0)
     510    function fvcn_get_post_rating_increment_link($postId = 0)
    554511    {
    555512        $id = fvcn_get_post_id($postId);
     
    572529 * @version 20120321
    573530 * @param int $postId
    574  * @return void
    575  */
    576 function fvcn_post_rating_decrement_link($postId=0)
     531 */
     532function fvcn_post_rating_decrement_link($postId = 0)
    577533{
    578534    echo fvcn_get_post_rating_decrement_link($postId);
     
    586542     * @return string
    587543     */
    588     function fvcn_get_post_rating_decrement_link($postId=0)
     544    function fvcn_get_post_rating_decrement_link($postId = 0)
    589545    {
    590546        $id = fvcn_get_post_id($postId);
     
    609565 * @return bool
    610566 */
    611 function fvcn_is_post_rated_by_current_user($postId=0)
     567function fvcn_is_post_rated_by_current_user($postId = 0)
    612568{
    613569    $id = fvcn_get_post_id($postId);
     
    622578 * @version 20120622
    623579 * @param int $postId
    624  * @return int
    625  */
    626 function fvcn_post_views($postId=0)
     580 */
     581function fvcn_post_views($postId = 0)
    627582{
    628583    echo fvcn_get_post_views($postId);
     
    636591     * @return int
    637592     */
    638     function fvcn_get_post_views($postId=0)
     593    function fvcn_get_post_views($postId = 0)
    639594    {
    640595        $postId = fvcn_get_post_id($postId);
     
    655610 * @version 20120306
    656611 * @param int $postId
    657  * @return void
    658  */
    659 function fvcn_post_status($postId=0)
     612 */
     613function fvcn_post_status($postId = 0)
    660614{
    661615    echo fvcn_get_post_status($postId);
     
    669623     * @return string
    670624     */
    671     function fvcn_get_post_status($postId=0)
     625    function fvcn_get_post_status($postId = 0)
    672626    {
    673627        $id = fvcn_get_post_id($postId);
     
    681635 *
    682636 * @version 20120321
    683  * @return void
    684637 */
    685638function fvcn_post_archive_link()
     
    696649    function fvcn_get_post_archive_link()
    697650    {
    698         $link = get_post_type_archive_link( fvcn_get_post_type());
     651        $link = get_post_type_archive_link(PostType::POST_TYPE_KEY);
    699652
    700653        return apply_filters('fvcn_get_post_archive_link', $link);
     
    709662 * @return bool
    710663 */
    711 function fvcn_is_post($postId=0)
     664function fvcn_is_post($postId = 0)
    712665{
    713666    $is_post = false;
    714667
    715     if (!empty($postId) && fvcn_get_post_type() == get_post_type($postId)) {
     668    if (!empty($postId) && PostType::POST_TYPE_KEY == get_post_type($postId)) {
    716669        $is_post = true;
    717670    }
     
    728681 * @return bool
    729682 */
    730 function fvcn_is_post_published($postId=0)
    731 {
    732     return fvcn_get_public_post_status() == fvcn_get_post_status( fvcn_get_post_id($postId));
     683function fvcn_is_post_published($postId = 0)
     684{
     685    return PostType::STATUS_PUBLISH == fvcn_get_post_status(fvcn_get_post_id($postId));
    733686}
    734687
     
    741694 * @return bool
    742695 */
    743 function fvcn_is_post_pending($postId=0)
    744 {
    745     return fvcn_get_pending_post_status() == fvcn_get_post_status( fvcn_get_post_id($postId));
     696function fvcn_is_post_pending($postId = 0)
     697{
     698    return PostType::STATUS_PENDING == fvcn_get_post_status(fvcn_get_post_id($postId));
    746699}
    747700
     
    754707 * @return bool
    755708 */
    756 function fvcn_is_post_trash($postId=0)
    757 {
    758     return fvcn_get_trash_post_status() == fvcn_get_post_status( fvcn_get_post_id($postId));
     709function fvcn_is_post_trash($postId = 0)
     710{
     711    return PostType::STATUS_TRASH == fvcn_get_post_status(fvcn_get_post_id($postId));
    759712}
    760713
     
    767720 * @return bool
    768721 */
    769 function fvcn_is_post_spam($postId=0)
    770 {
    771     return fvcn_get_spam_post_status() == fvcn_get_post_status( fvcn_get_post_id($postId));
     722function fvcn_is_post_spam($postId = 0)
     723{
     724    return PostType::STATUS_SPAM == fvcn_get_post_status(fvcn_get_post_id($postId));
    772725}
    773726
     
    780733 * @return bool
    781734 */
    782 function fvcn_is_post_private($postId=0)
    783 {
    784     return fvcn_get_private_post_status() == fvcn_get_post_status( fvcn_get_post_id($postId));
     735function fvcn_is_post_private($postId = 0)
     736{
     737    return PostType::STATUS_PRIVATE == fvcn_get_post_status(fvcn_get_post_id($postId));
    785738}
    786739
     
    793746 * @return bool
    794747 */
    795 function fvcn_is_post_anonymous($postId=0)
     748function fvcn_is_post_anonymous($postId = 0)
    796749{
    797750    $id = fvcn_get_post_id($postId);
     
    821774    $retval = false;
    822775
    823     if (is_singular(fvcn_get_post_type())) {
     776    if (is_singular(PostType::POST_TYPE_KEY)) {
    824777        $retval = true;
    825778    }
     
    839792    $retval = false;
    840793
    841     if (is_post_type_archive( fvcn_get_post_type())) {
     794    if (is_post_type_archive(PostType::POST_TYPE_KEY)) {
    842795        $retval = true;
    843796    }
     
    857810    $retval = false;
    858811
    859     if (is_tax( fvcn_get_post_tag_id())) {
     812    if (is_tax(fvcn_get_post_tag_id())) {
    860813        $retval = true;
    861814    }
     
    870823 * @version 20120306
    871824 * @param int $postId
    872  * @return void
    873  */
    874 function fvcn_post_author($postId=0)
     825 */
     826function fvcn_post_author($postId = 0)
    875827{
    876828    echo fvcn_get_post_author($postId);
     
    884836     * @return string
    885837     */
    886     function fvcn_get_post_author($postId=0)
     838    function fvcn_get_post_author($postId = 0)
    887839    {
    888840        $id = fvcn_get_post_id($postId);
     
    903855 * @version 20120306
    904856 * @param int $postId
    905  * @return void
    906  */
    907 function fvcn_post_author_id($postId=0)
     857 */
     858function fvcn_post_author_id($postId = 0)
    908859{
    909860    echo fvcn_get_post_author_id($postId);
     
    917868     * @return string
    918869     */
    919     function fvcn_get_post_author_id($postId=0)
     870    function fvcn_get_post_author_id($postId = 0)
    920871    {
    921872        $id = fvcn_get_post_id($postId);
     
    931882 * @version 20120306
    932883 * @param int $postId
    933  * @return void
    934  */
    935 function fvcn_post_author_display_name($postId=0)
     884 */
     885function fvcn_post_author_display_name($postId = 0)
    936886{
    937887    echo fvcn_get_post_author_display_name($postId);
     
    945895     * @return string
    946896     */
    947     function fvcn_get_post_author_display_name($postId=0)
     897    function fvcn_get_post_author_display_name($postId = 0)
    948898    {
    949899        $id = fvcn_get_post_id($postId);
     
    964914 * @version 20120306
    965915 * @param int $postId
    966  * @return void
    967  */
    968 function fvcn_post_author_email($postId=0)
     916 */
     917function fvcn_post_author_email($postId = 0)
    969918{
    970919    echo fvcn_get_post_author_email($postId);
     
    978927     * @return string
    979928     */
    980     function fvcn_get_post_author_email($postId=0)
     929    function fvcn_get_post_author_email($postId = 0)
    981930    {
    982931        $id = fvcn_get_post_id($postId);
     
    998947 * @param int $postId
    999948 * @param int $size
    1000  * @return void
    1001  */
    1002 function fvcn_post_author_avatar($postId=0, $size=40)
     949 */
     950function fvcn_post_author_avatar($postId = 0, $size=40)
    1003951{
    1004952    echo fvcn_get_post_author_avatar($postId, $size);
     
    1013961     * @return string
    1014962     */
    1015     function fvcn_get_post_author_avatar($postId=0, $size=40)
     963    function fvcn_get_post_author_avatar($postId = 0, $size=40)
    1016964    {
    1017965        $avatar = get_avatar(fvcn_get_post_author_email($postId), $size);
     
    1026974 * @version 20120306
    1027975 * @param int $postId
    1028  * @return void
    1029  */
    1030 function fvcn_post_author_website($postId=0)
     976 */
     977function fvcn_post_author_website($postId = 0)
    1031978{
    1032979    echo fvcn_get_post_author_website($postId);
     
    1040987     * @return string
    1041988     */
    1042     function fvcn_get_post_author_website($postId=0)
     989    function fvcn_get_post_author_website($postId = 0)
    1043990    {
    1044991        $id = fvcn_get_post_id($postId);
     
    10591006 * @version 20120305
    10601007 * @param int $postId
    1061  * @return void
    1062  */
    1063 function fvcn_post_author_link($postId=0)
     1008 */
     1009function fvcn_post_author_link($postId = 0)
    10641010{
    10651011    echo fvcn_get_post_author_link($postId);
     
    10731019     * @return string
    10741020     */
    1075     function fvcn_get_post_author_link($postId=0)
     1021    function fvcn_get_post_author_link($postId = 0)
    10761022    {
    10771023        $id = fvcn_get_post_id($postId);
     
    10921038 * @version 20120311
    10931039 * @param int $postId
    1094  * @return void
    1095  */
    1096 function fvcn_post_author_ip($postId=0)
     1040 */
     1041function fvcn_post_author_ip($postId = 0)
    10971042{
    10981043    echo fvcn_get_post_author_ip($postId);
     
    11061051     * @return string
    11071052     */
    1108     function fvcn_get_post_author_ip($postId=0)
     1053    function fvcn_get_post_author_ip($postId = 0)
    11091054    {
    11101055        $id = fvcn_get_post_id($postId);
     
    11211066 * @version 20120322
    11221067 * @param int $postId
    1123  * @return void
    1124  */
    1125 function fvcn_post_author_ua($postId=0)
     1068 */
     1069function fvcn_post_author_ua($postId = 0)
    11261070{
    11271071    echo fvcn_get_post_author_ua($postId);
     
    11351079     * @return string
    11361080     */
    1137     function fvcn_get_post_author_ua($postId=0)
     1081    function fvcn_get_post_author_ua($postId = 0)
    11381082    {
    11391083        $id = fvcn_get_post_id($postId);
     
    11491093 *
    11501094 * @version 20120229
    1151  * @return void
    11521095 */
    11531096function fvcn_post_tag_id()
     
    11591102     * fvcn_get_post_tag_id()
    11601103     *
     1104     * @return string
     1105     * @version 20171111
     1106     */
     1107    function fvcn_get_post_tag_id()
     1108    {
     1109        return PostType::TAG_TYPE_KEY;
     1110    }
     1111
     1112
     1113/**
     1114 * fvcn_post_tag_slug()
     1115 *
     1116 * @version 20120325
     1117 */
     1118function fvcn_post_tag_slug()
     1119{
     1120    echo fvcn_get_post_tag_slug();
     1121}
     1122
     1123    /**
     1124     * fvcn_get_post_tag_slug()
     1125     *
    11611126     * @version 20120710
    11621127     * @return string
    11631128     */
    1164     function fvcn_get_post_tag_id()
    1165     {
    1166         return apply_filters('fvcn_get_post_tag_id', FvCommunityNews_Registry::get('postTagId'));
    1167     }
    1168 
    1169 
    1170 /**
    1171  * fvcn_post_tag_slug()
    1172  *
    1173  * @version 20120325
    1174  * @return void
    1175  */
    1176 function fvcn_post_tag_slug()
    1177 {
    1178     echo fvcn_get_post_tag_slug();
    1179 }
    1180 
    1181     /**
    1182      * fvcn_get_post_tag_slug()
    1183      *
    1184      * @version 20120710
    1185      * @return string
    1186      */
    11871129    function fvcn_get_post_tag_slug()
    11881130    {
    1189         return apply_filters('fvcn_get_post_tag_slug', FvCommunityNews_Registry::get('postTagSlug'));
     1131        return apply_filters('fvcn_get_post_tag_slug', Registry::get('postTagSlug'));
    11901132    }
    11911133
     
    11971139 * @param int $postId
    11981140 * @param string|array $args
    1199  * @return void
    1200  */
    1201 function fvcn_post_tag_list($postId=0, $args='')
     1141 */
     1142function fvcn_post_tag_list($postId = 0, $args='')
    12021143{
    12031144    echo fvcn_get_post_tag_list($postId, $args);
     
    12121153     * @return string
    12131154     */
    1214     function fvcn_get_post_tag_list($postId=0, $args='')
     1155    function fvcn_get_post_tag_list($postId = 0, $args='')
    12151156    {
    12161157        $id = fvcn_get_post_id($postId);
     
    12361177 *
    12371178 * @version 20120307
    1238  * @return void
    12391179 */
    12401180function fvcn_post_form_fields()
     
    12441184    <input type="hidden" name="fvcn_post_form_action" id="fvcn_post_form_action" value="fvcn-new-post" />
    12451185    <?php wp_nonce_field('fvcn-new-post', 'fvcn_post_form_nonce'); ?>
    1246     <?php $value = base64_encode( time()); ?>
     1186    <?php $value = base64_encode(time()); ?>
    12471187    <input type="hidden" name="fvcn_post_form_time_key" id="fvcn_post_form_time_key" value="<?php echo $value; ?>" />
    12481188
     
    12561196 * @version 20120706
    12571197 * @param string $field
    1258  * @return void
    12591198 */
    12601199function fvcn_post_form_field_error($field)
    12611200{
    1262     $errors = FvCommunityNews_Container::getInstance()->getWpError()->get_error_messages($field);
     1201    $errors = Container::getInstance()->getWpError()->get_error_messages($field);
    12631202
    12641203    if (empty($errors)) {
     
    12801219 *
    12811220 * @version 20120306
    1282  * @return void
    12831221 */
    12841222function fvcn_post_form_author_name_label()
     
    12951233    function fvcn_get_post_form_author_name_label()
    12961234    {
    1297         $label = esc_attr( fvcn_get_option('_fvcn_post_form_author_name_label'));
     1235        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_author_name_label'));
    12981236
    12991237        return apply_filters('fvcn_get_post_form_author_name_label', $label);
     
    13041242 *
    13051243 * @version 20120306
    1306  * @return void
    13071244 */
    13081245function fvcn_post_form_author_name()
     
    13331270 *
    13341271 * @version 20120306
    1335  * @return void
    13361272 */
    13371273function fvcn_post_form_author_email_label()
     
    13481284    function fvcn_get_post_form_author_email_label()
    13491285    {
    1350         $label = esc_attr( fvcn_get_option('_fvcn_post_form_author_email_label'));
     1286        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_author_email_label'));
    13511287
    13521288        return apply_filters('fvcn_get_post_form_author_email_label', $label);
     
    13571293 *
    13581294 * @version 20120306
    1359  * @return void
    13601295 */
    13611296function fvcn_post_form_author_email()
     
    13861321 *
    13871322 * @version 20120306
    1388  * @return void
    13891323 */
    13901324function fvcn_post_form_title_label()
     
    14011335    function fvcn_get_post_form_title_label()
    14021336    {
    1403         $label = esc_attr( fvcn_get_option('_fvcn_post_form_title_label'));
     1337        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_title_label'));
    14041338
    14051339        return apply_filters('fvcn_get_post_form_title_label', $label);
     
    14101344 *
    14111345 * @version 20120306
    1412  * @return void
    14131346 */
    14141347function fvcn_post_form_title()
     
    14391372 *
    14401373 * @version 20120307
    1441  * @return void
    14421374 */
    14431375function fvcn_post_form_link_label()
     
    14541386    function fvcn_get_post_form_link_label()
    14551387    {
    1456         $label = esc_attr( fvcn_get_option('_fvcn_post_form_link_label'));
     1388        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_link_label'));
    14571389
    14581390        return apply_filters('fvcn_get_post_form_link_label', $label);
     
    14631395 *
    14641396 * @version 20120307
    1465  * @return void
    14661397 */
    14671398function fvcn_post_form_link()
     
    14951426function fvcn_is_post_form_link_required()
    14961427{
    1497     return apply_filters('fvcn_is_post_form_link_required', (bool) fvcn_get_option('_fvcn_post_form_link_required'));
     1428    return apply_filters('fvcn_is_post_form_link_required', (bool) Options::fvcnGetOption('_fvcn_post_form_link_required'));
    14981429}
    14991430
     
    15031434 *
    15041435 * @version 20120306
    1505  * @return void
    15061436 */
    15071437function fvcn_post_form_content_label()
     
    15181448    function fvcn_get_post_form_content_label()
    15191449    {
    1520         $label = esc_attr( fvcn_get_option('_fvcn_post_form_content_label'));
     1450        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_content_label'));
    15211451
    15221452        return apply_filters('fvcn_get_post_form_content_label', $label);
     
    15271457 *
    15281458 * @version 20120306
    1529  * @return void
    15301459 */
    15311460function fvcn_post_form_content()
     
    15561485 *
    15571486 * @version 20120306
    1558  * @return void
    15591487 */
    15601488function fvcn_post_form_tags_label()
     
    15711499    function fvcn_get_post_form_tags_label()
    15721500    {
    1573         $label = esc_attr( fvcn_get_option('_fvcn_post_form_tags_label'));
     1501        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_tags_label'));
    15741502
    15751503        return apply_filters('fvcn_get_post_form_tags_label', $label);
     
    15801508 *
    15811509 * @version 20120306
    1582  * @return void
    15831510 */
    15841511function fvcn_post_form_tags()
     
    16121539function fvcn_is_post_form_tags_required()
    16131540{
    1614     return apply_filters('fvcn_is_post_form_tags_required', (bool) fvcn_get_option('_fvcn_post_form_tags_required'));
     1541    return apply_filters('fvcn_is_post_form_tags_required', (bool) Options::fvcnGetOption('_fvcn_post_form_tags_required'));
    16151542}
    16161543
     
    16201547 *
    16211548 * @version 20120306
    1622  * @return void
    16231549 */
    16241550function fvcn_post_form_thumbnail_label()
     
    16351561    function fvcn_get_post_form_thumbnail_label()
    16361562    {
    1637         $label = esc_attr( fvcn_get_option('_fvcn_post_form_thumbnail_label'));
     1563        $label = esc_attr(Options::fvcnGetOption('_fvcn_post_form_thumbnail_label'));
    16381564
    16391565        return apply_filters('fvcn_get_post_form_thumbnail_label', $label);
     
    16481574function fvcn_is_post_form_thumbnail_enabled()
    16491575{
    1650     return apply_filters('fvcn_is_post_form_thumbnail_enabled', (bool) fvcn_get_option('_fvcn_post_form_thumbnail_enabled'));
     1576    return apply_filters('fvcn_is_post_form_thumbnail_enabled', (bool) Options::fvcnGetOption('_fvcn_post_form_thumbnail_enabled'));
    16511577}
    16521578
     
    16591585function fvcn_is_post_form_thumbnail_required()
    16601586{
    1661     return apply_filters('fvcn_is_post_form_thumbnail_required', (bool) fvcn_get_option('_fvcn_post_form_thumbnail_required'));
     1587    return apply_filters('fvcn_is_post_form_thumbnail_required', (bool) Options::fvcnGetOption('_fvcn_post_form_thumbnail_required'));
    16621588}
    16631589
     
    16901616        }
    16911617
    1692         return fvcn_get_public_post_status() == fvcn_get_post_status($_GET['fvcn_added']);
    1693     }
     1618        return PostType::STATUS_PUBLISH == fvcn_get_post_status($_GET['fvcn_added']);
     1619    }
  • fv-community-news/trunk/src/Template/tag-functions.php

    r1763901 r1763902  
    11<?php
    2 
    3 /**
    4  * fvcn-tag-template.php
    5  *
    6  * Tag Template
    7  *
    8  * @package FV Community News
    9  * @subpackage Template
    10  * @author Frank Verhoeven
    11  */
    12 
    13 if (!defined('ABSPATH')) {
    14     exit;
    15 }
    16 
    172
    183/**
     
    216 * @version 20120716
    227 * @param string|array $args
    23  * @return void
    248 */
    259function fvcn_tag_cloud($args='')
    2610{
    27     $default = ['taxonomy'=>fvcn_get_post_tag_id()];
     11    $default = ['taxonomy' => fvcn_get_post_tag_id()];
    2812    $args = wp_parse_args($args, $default);
    2913
    3014    wp_tag_cloud($args);
    3115}
    32 
  • fv-community-news/trunk/src/Template/user-functions.php

    r1763901 r1763902  
    11<?php
    22
     3use FvCommunityNews\Post\PostType;
     4
    35/**
    4  * fvcn-user-template.php
     6 * fvcn_is_anonymous()
    57 *
    6  * User Template
     8 * @version 20120229
     9 * @return bool
     10 */
     11function fvcn_is_anonymous() {
     12    if (!is_user_logged_in()) {
     13        $is_anonymous = true;
     14    } else {
     15        $is_anonymous = false;
     16    }
     17
     18    return apply_filters('fvcn_is_anonymous', $is_anonymous);
     19}
     20
     21/**
     22 * fvcn_get_current_author_ip()
    723 *
    8  * @package    FV Community News
    9  * @subpackage Template
    10  * @author Frank Verhoeven
     24 * @version 20120229
     25 * @return string
    1126 */
     27function fvcn_get_current_author_ip() {
     28    $ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
    1229
    13 if (!defined('ABSPATH')) {
    14     die('Direct access is not allowed!');
     30    return apply_filters('fvcn_get_current_author_ip', $ip);
     31}
     32
     33/**
     34 * fvcn_get_current_author_ua()
     35 *
     36 * @version 20120229
     37 * @return string
     38 */
     39function fvcn_get_current_author_ua() {
     40    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
     41        $ua = substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
     42    } else {
     43        $ua = '';
     44    }
     45
     46    return apply_filters('fvcn_get_current_author_ua', $ua);
    1547}
    1648
     
    1951 *
    2052 * @version 20120307
    21  * @uses fvcn_get_user_id()
    22  * @param int $user_id
    23  * @return void
     53 * @param int $userId
    2454 */
    25 function fvcn_user_id($user_id=0) {
    26     echo fvcn_get_user_id($user_id);
     55function fvcn_user_id($userId = 0) {
     56    echo fvcn_get_user_id($userId);
    2757}
    2858
     
    3161     *
    3262     * @version 20120307
    33      * @uses fvcn_is_anonymous()
    34      * @uses fvcn_get_current_user_id()
    35      * @uses apply_filters()
    36      * @param int $user_id
     63                 * @param int $userId
    3764     * @return int
    3865     */
    39     function fvcn_get_user_id($user_id=0) {
    40         if (!empty($user_id) && is_numeric($user_id)) {
    41             $id = $user_id;
     66    function fvcn_get_user_id($userId = 0) {
     67        if (!empty($userId) && is_numeric($userId)) {
     68            $id = $userId;
    4269
    4370        } elseif (!fvcn_is_anonymous()) {
     
    5683 *
    5784 * @version 20120229
    58  * @uses fvcn_get_current_user_id()
    59  * @return void
    6085 */
    6186function fvcn_current_user_id() {
     
    6792     *
    6893     * @version 20120229
    69      * @uses wp_get_current_user()
    70      * @uses apply_filters()
    71      * @return int
     94             * @return int
    7295     */
    7396    function fvcn_get_current_user_id() {
     
    82105 *
    83106 * @version 20120307
    84  * @uses fvcn_get_current_user_name()
    85  * @return void
    86107 */
    87108function fvcn_current_user_name() {
     
    93114     *
    94115     * @version 20120307
    95      * @uses $user_identity
    96      * @uses apply_filters()
    97      * @return string
     116             * @return string
    98117     */
    99118    function fvcn_get_current_user_name() {
    100         global $user_identity;
     119        global $userIdentity;
    101120
    102         return apply_filters('fvcn_get_current_user_name', $user_identity);
     121        return apply_filters('fvcn_get_current_user_name', $userIdentity);
    103122    }
    104123
     
    108127 *
    109128 * @version 20120323
    110  * @uses fvcn_get_user_id()
    111  * @uses fvcn_get_public_post_status()
    112  * @uses fvcn_has_posts()
    113  * @uses apply_filters()
     129 * @param int $userId
     130 * @param string $post_status
    114131 * @return bool
    115132 */
    116 function fvcn_has_user_posts($user_id=0, $post_status='') {
    117     $id = fvcn_get_user_id($user_id);
     133function fvcn_has_user_posts($userId=0, $post_status='') {
     134    $id = fvcn_get_user_id($userId);
    118135
    119136    if (0 == $id) {
     
    121138    } else {
    122139        if (empty($post_status)) {
    123             $post_status = fvcn_get_public_post_status();
     140            $post_status = PostType::STATUS_PUBLISH;
    124141        }
    125142
     
    134151    return apply_filters('fvcn_has_user_posts', (bool) $retval);
    135152}
    136 
    137 
    138 
    139 
    140 
    141 
    142 
    143 
    144 
    145 
    146 
    147 
    148 
  • fv-community-news/trunk/src/Version.php

    r1760963 r1763902  
    22
    33namespace FvCommunityNews;
     4
     5use FvCommunityNews;
    46
    57/**
     
    1315     * @var string
    1416     */
    15     const CURRENT_VERSION = '3.1';
    16 
     17    const CURRENT_VERSION = FvCommunityNews::VERSION;
    1718    /**
    1819     * @var string
    1920     */
    2021    const API_VERSION_CURRENT = 'https://api.frankverhoeven.me/fvcn/1.0/versions/current';
    21 
    2222    /**
    2323     * @var string
     
    5555                    'wordpress_version' => $wp_version,
    5656                    'plugin_version'    => self::getCurrentVersion(),
     57                    'php_version'       => phpversion(),
    5758                ],
    5859            ]);
  • fv-community-news/trunk/src/Widget/Form.php

    r1760963 r1763902  
    8989     *
    9090     * @param array $instance
    91      * @return void
    92      * @version 20120306
     91         * @version 20120306
    9392     */
    9493    public function form($instance)
  • fv-community-news/trunk/src/Widget/ListPosts.php

    r1760963 r1763902  
    33namespace FvCommunityNews\Widget;
    44
     5use FvCommunityNews\Registry;
    56use WP_Widget;
    67
     
    4243     * @param mixed $args
    4344     * @param array $instance
    44      * @return void
    45      * @version 20120710
     45         * @version 20120710
    4646     */
    4747    public function widget($args, $instance)
     
    5151
    5252        $title = apply_filters('fvcn_list_posts_widget_title', $instance['title']);
    53         $num_posts = !empty( $instance['num_posts']) ? $instance['num_posts'] : '5';
     53        $num_posts = !empty($instance['num_posts']) ? $instance['num_posts'] : '5';
    5454
    55         $registry = \FvCommunityNews_Registry::getInstance();
    56         $registry->widgetShowThumbnail = !empty( $instance['thumbnail']) ? true : false;
    57         $registry->widgetShowViewAll = !empty( $instance['view_all']) ? true : false;
     55        $registry = Registry::getInstance();
     56        $registry->widgetShowThumbnail = !empty($instance['thumbnail']) ? true : false;
     57        $registry->widgetShowViewAll = !empty($instance['view_all']) ? true : false;
    5858
    5959        $options = [
  • fv-community-news/trunk/src/Widget/TagCloud.php

    r1760963 r1763902  
    8181     *
    8282     * @param array $instance
    83      * @return void
    84      * @version 20120411
     83         * @version 20120411
    8584     */
    8685    public function form($instance)
Note: See TracChangeset for help on using the changeset viewer.