Giter Club home page Giter Club logo

outdated-notice's Introduction

Outdated Notice

Sample plugin using the WordPress plugin boilerplate where the user can customize the plugin for the position of the text notice as well as the day treshold for a post to be considered as outdated.

This code is used as a support for article series "Speed up Development Using the WordPress Plugin Boilerplate" for SitePoint

Article in series:

outdated-notice's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

marcoslkz

outdated-notice's Issues

Settings fields and section callbacks not working

`<?php

/**

/**

  • The admin-specific functionality of the plugin.

  • Defines the plugin name, version, and two examples hooks for how to

  • enqueue the admin-specific stylesheet and JavaScript.

  • @Package Sharefile_Connector

  • @subpackage Sharefile_Connector/admin

  • @author Azmat Mehmood [email protected]
    */
    class Sharefile_Connector_Admin
    {

    /**

    • The ID of this plugin.
    • @SInCE 1.0.0
    • @access private
    • @var string $plugin_name The ID of this plugin.
      */
      private $plugin_name;

    /**

    • The version of this plugin.
    • @SInCE 1.0.0
    • @access private
    • @var string $version The current version of this plugin.
      */
      private $version;

    /**

    • Pluign's name as prefix for all the internal methods
    • @SInCE 1.0.0
    • @access private
    • @var string $plugin_name The ID of this plugin.
      */
      private $option_name = 'sfc_';

    /**

    • Initialize the class and set its properties.

    • @SInCE 1.0.0

    • @param string $plugin_name The name of this plugin.

    • @param string $version The version of this plugin.
      */
      public function __construct($plugin_name, $version)
      {

      $this->plugin_name = $plugin_name;
      $this->version = $version;

    }

    /**

    • Register the stylesheets for the admin area.

    • @SInCE 1.0.0
      */
      public function enqueue_styles()
      {

      /**

      • This function is provided for demonstration purposes only.
      • An instance of this class should be passed to the run() function
      • defined in Sharefile_Connector_Loader as all of the hooks are defined
      • in that particular class.
      • The Sharefile_Connector_Loader will then create the relationship
      • between the defined hooks and the functions defined in this
      • class.
        */

      wp_enqueue_style($this->plugin_name, plugin_dir_url(FILE) . 'css/sharefile-connector-admin.css', array(), $this->version, 'all');

    }

    /**

    • Register the JavaScript for the admin area.

    • @SInCE 1.0.0
      */
      public function enqueue_scripts()
      {

      /**

      • This function is provided for demonstration purposes only.
      • An instance of this class should be passed to the run() function
      • defined in Sharefile_Connector_Loader as all of the hooks are defined
      • in that particular class.
      • The Sharefile_Connector_Loader will then create the relationship
      • between the defined hooks and the functions defined in this
      • class.
        */

      wp_enqueue_script($this->plugin_name, plugin_dir_url(FILE) . 'js/sharefile-connector-admin.js', array('jquery'), $this->version, false);

    }

    public function config_page()
    {
    $this->plugin_screen_hook_suffix = add_options_page(
    __( 'SF Connector Config', 'sharefile-config' ),
    __( 'SF Connector Config', 'sharefile-config' ),
    'manage_options',
    $this->plugin_name,
    array($this, 'display_config_page_callback')
    );
    }

    public function display_config_page_callback()
    {
    include_once 'partials/sharefile-connector-admin-display.php';
    }

    public function register_setting()
    {
    // Add General Section
    add_settings_section(
    $this->option_name.'general',
    __( 'API Credentials', 'sharefile-config' ),
    array($this, $this->option_name.'general_section_callback'),
    $this->plugin_name
    );

     add_settings_field( 
     	$this->option_name.'hostname', 
     	__( 'Host Name', 'sharefile-config' ), 
     	array($this, $this->option_name.'hostname_callback'), 
     	$this->plugin_name, 
     	$this->option_name.'general', 
     	array('label_for' => $this->option_name.'hostname')
     );
     add_settings_field( 
     	$this->option_name.'username', 
     	__( 'ShareFile Username', 'sharefile-config' ), 
     	array($this, $this->option_name.'username_callback'), 
     	$this->plugin_name, 
     	$this->option_name.'general', 
     	array('label_for' => $this->option_name.'username')
     );
     add_settings_field( 
     	$this->option_name.'password', 
     	__( 'ShareFile Password', 'sharefile-config' ), 
     	array($this, $this->option_name.'password_callback'), 
     	$this->plugin_name, 
     	$this->option_name.'general', 
     	array('label_for' => $this->option_name.'password')
     );
     add_settings_field( 
     	$this->option_name.'client_id', 
     	__( 'ShareFile Client_id', 'sharefile-config' ), 
     	array($this, $this->option_name.'client_id_callback'), 
     	$this->plugin_name, 
     	$this->option_name.'general', 
     	array('label_for' => $this->option_name.'client_id')
     );
     add_settings_field( 
     	$this->option_name.'client_secret', 
     	__( 'ShareFile Client_secret', 'sharefile-config' ), 
     	array($this, $this->option_name.'client_secret_callback'), 
     	$this->plugin_name, 
     	$this->option_name.'general', 
     	array('label_for' => $this->option_name.'client_secret')
     );
    
     register_setting( $this->plugin_name, $this->option_name.'hostname' );
     register_setting( $this->plugin_name, $this->option_name.'username' );
     register_setting( $this->plugin_name, $this->option_name.'password' );
     register_setting( $this->plugin_name, $this->option_name.'client_id' );
     register_setting( $this->plugin_name, $this->option_name.'client_secret' );
    

    }

    public function sfc_general_section_callback()
    {
    echo '

    '.__( 'Please put your API credentials from ShareFile here.', 'sharefile-config' ).'

    ' ;
    }

    public function sfc_hostname_callback()
    {
    ?>

     <?php
    

    }

    public function sfc_username_callback()
    {
    ?>

     <?php
    

    }

    public function sfc_password_callback()
    {
    ?>

     <?php
    

    }

    public function sfc_client_id_callback()
    {
    ?>

     <?php
    

    }

    public function sfc_client_secret_callback()
    {
    ?>

     <?php
    

    }

}
`

everything is same but no field on page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.