Plugin Directory

Changeset 2087009


Ignore:
Timestamp:
05/13/2019 03:34:09 PM (7 years ago)
Author:
fayne
Message:

Options page added

Location:
be-lazy/trunk
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • be-lazy/trunk/app/Controllers/Backend.php

    r2086714 r2087009  
    77        public function __construct()
    88        {
     9            add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
     10            add_action('admin_menu', [$this, 'add_menu']);
     11            add_action('admin_init', [$this, 'register_settings']);
    912        }
     13
     14        public function enqueue_styles()
     15        {
     16            wp_enqueue_style('be-lazy', BE_LAZY_URL_CSS .'be-lazy-admin.css', [], BE_LAZY_VERSION);
     17        }
     18
     19        public function add_menu()
     20        {
     21            add_menu_page(
     22                'Be Lazy',
     23                'Be Lazy',
     24                'manage_options',
     25                BE_LAZY_SLUG,
     26                [$this, 'show_options_page'],
     27                BE_LAZY_URL_IMG .'/be-lazy.svg',
     28                999
     29            );
     30        }
     31
     32        public function show_options_page()
     33        {
     34            require_once BE_LAZY_DIR_VIEWS .'options_page.php';
     35        }
     36
     37        public function register_settings()
     38        {
     39            register_setting(BE_LAZY_SLUG, BE_LAZY_SLUG_DB .'_active', [
     40              //  'default' => '1'
     41            ]);
     42        }
    1043    }
  • be-lazy/trunk/app/Controllers/Frontend.php

    r2086752 r2087009  
    77        public function __construct()
    88        {
    9             add_action('wp_enqueue_scripts', [$this, 'enqueue_styles']);
    10             add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']);
    11 
    12             add_filter('the_content', [$this, 'filter_content'], 100);
     9            switch(get_option(BE_LAZY_SLUG_DB .'_active'))
     10            {
     11                case '0':
     12                case '1':
     13                    add_action('wp_enqueue_scripts', [$this, 'enqueue_styles']);
     14                    add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']);
     15                    add_filter('the_content', [$this, 'filter_content'], 100);
     16                    break;
     17            }
    1318        }
    1419
    1520        public function enqueue_styles()
    1621        {
    17             wp_enqueue_style('be-lazy', BE_LAZY_URL_CSS .'be-lazy.css', [], '1.0.0');
     22            wp_enqueue_style('be-lazy', BE_LAZY_URL_CSS .'be-lazy.css', [], BE_LAZY_VERSION);
    1823        }
    1924
    2025        public function enqueue_scripts()
    2126        {
    22             wp_enqueue_script('be-lazy', BE_LAZY_URL_JS .'be-lazy.js', [], '1.0.0', true);
     27            wp_enqueue_script('be-lazy', BE_LAZY_URL_JS .'be-lazy.js', [], BE_LAZY_VERSION, true);
    2328        }
    2429
  • be-lazy/trunk/config/constants.php

    r2086730 r2087009  
    11<?php
    22
    3     /**
    4      * @var string Base directory
    5      */
    63    define('BE_LAZY_DIR', dirname(__DIR__) . '/');
    74
    8     /**
    9      * @var string Base url
    10      */
    115    define('BE_LAZY_URL', plugin_dir_url(__DIR__));
    126
    13     /**
    14      * @var string Plugin slug
    15      */
    167    const BE_LAZY_SLUG = 'be-lazy';
    178
    18     /**
    19      * @var string JS directory
    20      */
     9    const BE_LAZY_SLUG_DB = 'be_lazy';
     10
     11    const BE_LAZY_VERSION = '1.0';
     12
     13    const BE_LAZY_DIR_VIEWS = BE_LAZY_DIR .'app/Views/';
     14
    2115    const BE_LAZY_URL_JS = BE_LAZY_URL . 'assets/js/';
    2216
    23     /**
    24      * @var string CSS directory
    25      */
    2617    const BE_LAZY_URL_CSS = BE_LAZY_URL . 'assets/css/';
     18
     19    const BE_LAZY_URL_IMG = BE_LAZY_URL . 'assets/img/';
Note: See TracChangeset for help on using the changeset viewer.