├── .gitignore ├── README.md ├── plugins ├── index.php └── wp-spwh │ ├── LICENSE.txt │ ├── README.txt │ ├── admin │ ├── class-wp-spwh-admin.php │ ├── css │ │ └── wp-spwh-admin.css │ ├── index.php │ ├── js │ │ └── wp-spwh-admin.js │ └── partials │ │ └── wp-spwh-admin-display.php │ ├── includes │ ├── class-wp-spwh-activator.php │ ├── class-wp-spwh-deactivator.php │ ├── class-wp-spwh-i18n.php │ ├── class-wp-spwh-loader.php │ ├── class-wp-spwh.php │ └── index.php │ ├── index.php │ ├── languages │ └── wp-spwh.pot │ ├── public │ ├── class-wp-spwh-public.php │ ├── css │ │ └── wp-spwh-public.css │ ├── index.php │ ├── js │ │ └── wp-spwh-public.js │ └── partials │ │ └── wp-spwh-public-display.php │ ├── uninstall.php │ └── wp-spwh.php └── themes ├── index.php └── wp-headless ├── functions.php ├── index.php └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | # Don't upload zipped plugins 2 | *.zip 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JAMstack WordPress 2 | 3 | This project is a collection of [WordPress (WP)](https://codex.wordpress.org) utilities that I've made to help me with my [JAMstack](https://jamstack.org) setup. I generally write content on WP, build with [Gatsby](https://www.gatsbyjs.org), and host on [Netlify](https://www.netlify.com). 4 | 5 | *The directory structure is meant to mirror your `wp-content` folder.* 6 | 7 | ## Disclaimers 8 | 9 | I'm fairly new to WP development, so I'd appreciate any constructive critique that you're willing to give. Since I'm new, please understand that the **Caveat Emptor** is strong with this project. Please test this stuff in a safe dev environment so that it doesn't hurt your production site. 10 | 11 | I want to give credit where credit is due, but I sometimes read a tutorial, start a project, only to come back to it later having lost the original link. If I can credit the original author for the idea, I will. Thanks to the giants upon whose shoulders I stand. 12 | 13 | ## Plugins 14 | 15 | ### wp-spwh 16 | 17 | **WordPress Save-Post WebHook** 18 | 19 | This plugin sends a non-blocking POST request to your endpoint over HTTP/1.1 whenever [`save_post`](https://codex.wordpress.org/Plugin_API/Action_Reference/save_post) or `edit_post` is triggered and the `post_status` is `pubish`, `private`, or `trash`. The sending domain's origin is included in the headers. The `post_id`, `post_title`, and [`post_status`](https://codex.wordpress.org/Function_Reference/get_post_status) that triggered `save_post` are included in the body, as is the `api_key` (if you use that option). 20 | 21 | I made this because Netlify allows an incoming WebHook for publishing your site. I use this in the following way: 22 | 23 | 1. put my Gatsby site on GitHub and set up with Netlify 24 | 2. install wp-spwh into WP and set up with [incoming WebHook](https://www.netlify.com/docs/webhooks/) URL 25 | 3. comment upon, create, update, delete, or change privacy settings on some content 26 | 4. WebHook gets posted to Netlify, which triggers rebuild of site's content 27 | 28 | ## Themes 29 | 30 | ### wp-headless-cms 31 | 32 | **WordPress Headless CMS** 33 | 34 | ([original idea](https://blog.daftcode.pl/wordpress-as-a-headless-cms-b4144c626695)) 35 | 36 | This theme redirects requests so that no front-end content will be displayed to someone who has managed to get to your WP site's front-end. It has a `` tag redirect (primary) and a `window.location` redirect (backup) built in. I also included a Urchin Tracking Module (UTM) query parameter that identifies the soruce as "`wp_headless_cms_theme`". 37 | 38 | Since I generally have a self-hosted WP instance attached as a subdomain to the main site, I use this in the following way: 39 | 40 | 1. replace both instances of `www.example.com` using WP's theme editor, sending traffic to the `wp-admin` login page 41 | 2. check the checkbox "Discourage search engines from indexing this site" in WP's `Settings` > `Reading` section 42 | 43 | I also have added a `functions.php` file to contain various functions that might be helpful to using the REST API. Be sure to check that over so that you don't include undesired functionality. 44 | -------------------------------------------------------------------------------- /plugins/index.php: -------------------------------------------------------------------------------- 1 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /plugins/wp-spwh/README.txt: -------------------------------------------------------------------------------- 1 | === Plugin Name === 2 | Contributors: (this should be a list of wordpress.org userid's) 3 | Donate link: https://integrisweb.com 4 | Tags: webhook 5 | Requires at least: 4.8.2 6 | License: GPLv2 or later 7 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 8 | 9 | A plugin to notify an endpoint when content has been updated through `save_post` or `edit_post` hook, limited to certain statuses. 10 | 11 | == Description == 12 | 13 | A plugin to notify an endpoint when content has been updated through `save_post` or `edit_post` hook. Sends `origin` in header, `post_id`, `post_title`, `post_status`, and `api_key` in body. Only triggers when post status is `publish`, `private`, or `trash`. 14 | -------------------------------------------------------------------------------- /plugins/wp-spwh/admin/class-wp-spwh-admin.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Wp_Spwh_Admin { 24 | 25 | /** 26 | * The ID of this plugin. 27 | * 28 | * @since 1.0.0 29 | * @access private 30 | * @var string $plugin_name The ID of this plugin. 31 | */ 32 | private $plugin_name; 33 | 34 | /** 35 | * The version of this plugin. 36 | * 37 | * @since 1.0.0 38 | * @access private 39 | * @var string $version The current version of this plugin. 40 | */ 41 | private $version; 42 | 43 | /** 44 | * Initialize the class and set its properties. 45 | * 46 | * @since 1.0.0 47 | * @param string $plugin_name The name of this plugin. 48 | * @param string $version The version of this plugin. 49 | */ 50 | public function __construct( $plugin_name, $version ) { 51 | 52 | $this->plugin_name = $plugin_name; 53 | $this->version = $version; 54 | $this->wp_spwh_options = get_option($this->plugin_name); 55 | 56 | } 57 | 58 | /** 59 | * Register the stylesheets for the admin area. 60 | * 61 | * @since 1.0.0 62 | */ 63 | public function enqueue_styles() { 64 | 65 | /** 66 | * This function is provided for demonstration purposes only. 67 | * 68 | * An instance of this class should be passed to the run() function 69 | * defined in Wp_Spwh_Loader as all of the hooks are defined 70 | * in that particular class. 71 | * 72 | * The Wp_Spwh_Loader will then create the relationship 73 | * between the defined hooks and the functions defined in this 74 | * class. 75 | */ 76 | 77 | wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-spwh-admin.css', array(), $this->version, 'all' ); 78 | 79 | } 80 | 81 | /** 82 | * Register the JavaScript for the admin area. 83 | * 84 | * @since 1.0.0 85 | */ 86 | public function enqueue_scripts() { 87 | 88 | /** 89 | * This function is provided for demonstration purposes only. 90 | * 91 | * An instance of this class should be passed to the run() function 92 | * defined in Wp_Spwh_Loader as all of the hooks are defined 93 | * in that particular class. 94 | * 95 | * The Wp_Spwh_Loader will then create the relationship 96 | * between the defined hooks and the functions defined in this 97 | * class. 98 | */ 99 | 100 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-spwh-admin.js', array( 'jquery' ), $this->version, false ); 101 | 102 | } 103 | 104 | // Add a settings page for this plugin to the Settings menu. 105 | // http://codex.wordpress.org/Administration_Menus 106 | public function add_plugin_admin_menu() { 107 | add_options_page('Save Post WebHook Options', 'SP WebHook', 'manage_options', $this->plugin_name, array($this, 'display_plugin_setup_page')); 108 | } 109 | 110 | // Add settings action link to the plugins page. 111 | // https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name) 112 | public function add_action_links($links) { 113 | $settings_link = array( 114 | '' . __('Settings', $this->plugin_name) . '', 115 | ); 116 | return array_merge($settings_link, $links); 117 | } 118 | 119 | // Render the settings page for this plugin. 120 | public function display_plugin_setup_page() { 121 | include_once('partials/wp-spwh-admin-display.php'); 122 | } 123 | 124 | public function options_update() { 125 | register_setting($this->plugin_name, $this->plugin_name, array($this, 'validate')); 126 | } 127 | 128 | // Validate input. 129 | public function validate($input) { 130 | $valid = array(); 131 | 132 | // Endpoint. 133 | $valid['endpoint'] = esc_url($input['endpoint']); 134 | 135 | // API Key. 136 | $valid['api_key'] = sanitize_text_field($input['api_key']); 137 | 138 | return $valid; 139 | } 140 | 141 | public function send_notification_to_endpoint ($post_id) { 142 | $url = $this->wp_spwh_options['endpoint']; 143 | $api_key = $this->wp_spwh_options['api_key']; 144 | 145 | $status = get_post_status($post_id); 146 | $acceptable_status = array('publish', 'private', 'trash'); 147 | $filter = current_filter(); 148 | 149 | $title = get_the_title($post_id); 150 | $origin = site_url(); 151 | 152 | // Return early if this is a post revision from the 'save_post' action. 153 | if ($filter === 'save_post' && wp_is_post_revision($post_id) === false) { 154 | return; 155 | } 156 | 157 | // Return early if this isn't one of the statuses we should be watching for. 158 | if (in_array($status, $acceptable_status) === false) { 159 | return; 160 | } 161 | 162 | // Send the POST request. 163 | return wp_remote_post($url, array( 164 | 'method' => 'POST', 165 | 'httpversion' => '1.1', 166 | 'blocking' => false, 167 | 'headers' => array( 168 | 'origin' => $origin 169 | ), 170 | 'body' => array( 171 | 'post_id' => $post_id, 172 | 'post_title' => $title, 173 | 'post_status' => $status, 174 | 'api_key' => $api_key 175 | ) 176 | )); 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /plugins/wp-spwh/admin/css/wp-spwh-admin.css: -------------------------------------------------------------------------------- 1 | /** 2 | * All of the CSS for your admin-specific functionality should be 3 | * included in this file. 4 | */ -------------------------------------------------------------------------------- /plugins/wp-spwh/admin/index.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 |
18 | 19 |

20 | 21 |
22 | 23 | plugin_name); 26 | ?> 27 | 28 | plugin_name); 30 | do_settings_sections($this->plugin_name); 31 | ?> 32 |

This plugin sends a non-blocking POST request to your endpoint over HTTP/1.1 whenever save_post (codex link) or edit_post is triggered and the post_status is pubish, private, or trash. The sending domain’s origin is included in the headers. The post_id, post_title, and post_status (codex link) that triggered save_post are included in the body, as is the api_key (from the input, below).

33 | 34 | 35 |
36 | Set POST endpoint. 37 | 41 |

plugin_name); ?>

42 |
43 | 44 | 45 |
46 | Set POST API key. 47 | 51 |

If you have an API key, enter it for use in validating this request.

52 |
53 | 54 | 55 | 56 |
57 |
58 | -------------------------------------------------------------------------------- /plugins/wp-spwh/includes/class-wp-spwh-activator.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Wp_Spwh_Activator { 24 | 25 | /** 26 | * Short Description. (use period) 27 | * 28 | * Long Description. 29 | * 30 | * @since 1.0.0 31 | */ 32 | public static function activate() { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /plugins/wp-spwh/includes/class-wp-spwh-deactivator.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Wp_Spwh_Deactivator { 24 | 25 | /** 26 | * Short Description. (use period) 27 | * 28 | * Long Description. 29 | * 30 | * @since 1.0.0 31 | */ 32 | public static function deactivate() { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /plugins/wp-spwh/includes/class-wp-spwh-i18n.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | class Wp_Spwh_i18n { 28 | 29 | 30 | /** 31 | * Load the plugin text domain for translation. 32 | * 33 | * @since 1.0.0 34 | */ 35 | public function load_plugin_textdomain() { 36 | 37 | load_plugin_textdomain( 38 | 'wp-spwh', 39 | false, 40 | dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' 41 | ); 42 | 43 | } 44 | 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /plugins/wp-spwh/includes/class-wp-spwh-loader.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class Wp_Spwh_Loader { 25 | 26 | /** 27 | * The array of actions registered with WordPress. 28 | * 29 | * @since 1.0.0 30 | * @access protected 31 | * @var array $actions The actions registered with WordPress to fire when the plugin loads. 32 | */ 33 | protected $actions; 34 | 35 | /** 36 | * The array of filters registered with WordPress. 37 | * 38 | * @since 1.0.0 39 | * @access protected 40 | * @var array $filters The filters registered with WordPress to fire when the plugin loads. 41 | */ 42 | protected $filters; 43 | 44 | /** 45 | * Initialize the collections used to maintain the actions and filters. 46 | * 47 | * @since 1.0.0 48 | */ 49 | public function __construct() { 50 | 51 | $this->actions = array(); 52 | $this->filters = array(); 53 | 54 | } 55 | 56 | /** 57 | * Add a new action to the collection to be registered with WordPress. 58 | * 59 | * @since 1.0.0 60 | * @param string $hook The name of the WordPress action that is being registered. 61 | * @param object $component A reference to the instance of the object on which the action is defined. 62 | * @param string $callback The name of the function definition on the $component. 63 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. 64 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. 65 | */ 66 | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 67 | $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 68 | } 69 | 70 | /** 71 | * Add a new filter to the collection to be registered with WordPress. 72 | * 73 | * @since 1.0.0 74 | * @param string $hook The name of the WordPress filter that is being registered. 75 | * @param object $component A reference to the instance of the object on which the filter is defined. 76 | * @param string $callback The name of the function definition on the $component. 77 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. 78 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 79 | */ 80 | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 81 | $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 82 | } 83 | 84 | /** 85 | * A utility function that is used to register the actions and hooks into a single 86 | * collection. 87 | * 88 | * @since 1.0.0 89 | * @access private 90 | * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 91 | * @param string $hook The name of the WordPress filter that is being registered. 92 | * @param object $component A reference to the instance of the object on which the filter is defined. 93 | * @param string $callback The name of the function definition on the $component. 94 | * @param int $priority The priority at which the function should be fired. 95 | * @param int $accepted_args The number of arguments that should be passed to the $callback. 96 | * @return array The collection of actions and filters registered with WordPress. 97 | */ 98 | private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 99 | 100 | $hooks[] = array( 101 | 'hook' => $hook, 102 | 'component' => $component, 103 | 'callback' => $callback, 104 | 'priority' => $priority, 105 | 'accepted_args' => $accepted_args 106 | ); 107 | 108 | return $hooks; 109 | 110 | } 111 | 112 | /** 113 | * Register the filters and actions with WordPress. 114 | * 115 | * @since 1.0.0 116 | */ 117 | public function run() { 118 | 119 | foreach ( $this->filters as $hook ) { 120 | add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 121 | } 122 | 123 | foreach ( $this->actions as $hook ) { 124 | add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 125 | } 126 | 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /plugins/wp-spwh/includes/class-wp-spwh.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class Wp_Spwh { 31 | 32 | /** 33 | * The loader that's responsible for maintaining and registering all hooks that power 34 | * the plugin. 35 | * 36 | * @since 1.0.0 37 | * @access protected 38 | * @var Wp_Spwh_Loader $loader Maintains and registers all hooks for the plugin. 39 | */ 40 | protected $loader; 41 | 42 | /** 43 | * The unique identifier of this plugin. 44 | * 45 | * @since 1.0.0 46 | * @access protected 47 | * @var string $plugin_name The string used to uniquely identify this plugin. 48 | */ 49 | protected $plugin_name; 50 | 51 | /** 52 | * The current version of the plugin. 53 | * 54 | * @since 1.0.0 55 | * @access protected 56 | * @var string $version The current version of the plugin. 57 | */ 58 | protected $version; 59 | 60 | /** 61 | * Define the core functionality of the plugin. 62 | * 63 | * Set the plugin name and the plugin version that can be used throughout the plugin. 64 | * Load the dependencies, define the locale, and set the hooks for the admin area and 65 | * the public-facing side of the site. 66 | * 67 | * @since 1.0.0 68 | */ 69 | public function __construct() { 70 | if ( defined( 'PLUGIN_NAME_VERSION' ) ) { 71 | $this->version = PLUGIN_NAME_VERSION; 72 | } else { 73 | $this->version = '1.0.0'; 74 | } 75 | $this->plugin_name = 'wp-spwh'; 76 | 77 | $this->load_dependencies(); 78 | $this->set_locale(); 79 | $this->define_admin_hooks(); 80 | $this->define_public_hooks(); 81 | 82 | } 83 | 84 | /** 85 | * Load the required dependencies for this plugin. 86 | * 87 | * Include the following files that make up the plugin: 88 | * 89 | * - Wp_Spwh_Loader. Orchestrates the hooks of the plugin. 90 | * - Wp_Spwh_i18n. Defines internationalization functionality. 91 | * - Wp_Spwh_Admin. Defines all hooks for the admin area. 92 | * - Wp_Spwh_Public. Defines all hooks for the public side of the site. 93 | * 94 | * Create an instance of the loader which will be used to register the hooks 95 | * with WordPress. 96 | * 97 | * @since 1.0.0 98 | * @access private 99 | */ 100 | private function load_dependencies() { 101 | 102 | /** 103 | * The class responsible for orchestrating the actions and filters of the 104 | * core plugin. 105 | */ 106 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-spwh-loader.php'; 107 | 108 | /** 109 | * The class responsible for defining internationalization functionality 110 | * of the plugin. 111 | */ 112 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-spwh-i18n.php'; 113 | 114 | /** 115 | * The class responsible for defining all actions that occur in the admin area. 116 | */ 117 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wp-spwh-admin.php'; 118 | 119 | /** 120 | * The class responsible for defining all actions that occur in the public-facing 121 | * side of the site. 122 | */ 123 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wp-spwh-public.php'; 124 | 125 | $this->loader = new Wp_Spwh_Loader(); 126 | 127 | } 128 | 129 | /** 130 | * Define the locale for this plugin for internationalization. 131 | * 132 | * Uses the Wp_Spwh_i18n class in order to set the domain and to register the hook 133 | * with WordPress. 134 | * 135 | * @since 1.0.0 136 | * @access private 137 | */ 138 | private function set_locale() { 139 | 140 | $plugin_i18n = new Wp_Spwh_i18n(); 141 | 142 | $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 143 | 144 | } 145 | 146 | /** 147 | * Register all of the hooks related to the admin area functionality 148 | * of the plugin. 149 | * 150 | * @since 1.0.0 151 | * @access private 152 | */ 153 | private function define_admin_hooks() { 154 | 155 | $plugin_admin = new Wp_Spwh_Admin( $this->get_plugin_name(), $this->get_version() ); 156 | 157 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); 158 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); 159 | 160 | // Add menu item. 161 | $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' ); 162 | 163 | // Add Settings link to the plugin. 164 | $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' ); 165 | $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links' ); 166 | 167 | // Save or Update plugin options. 168 | $this->loader->add_action('admin_init', $plugin_admin, 'options_update'); 169 | 170 | // Hook into save_post action. 171 | $this->loader->add_action('save_post', $plugin_admin ,'send_notification_to_endpoint'); 172 | // Hook into edit_post action. 173 | $this->loader->add_action('edit_post', $plugin_admin ,'send_notification_to_endpoint'); 174 | } 175 | 176 | /** 177 | * Register all of the hooks related to the public-facing functionality 178 | * of the plugin. 179 | * 180 | * @since 1.0.0 181 | * @access private 182 | */ 183 | private function define_public_hooks() { 184 | 185 | $plugin_public = new Wp_Spwh_Public( $this->get_plugin_name(), $this->get_version() ); 186 | 187 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); 188 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 189 | } 190 | 191 | /** 192 | * Run the loader to execute all of the hooks with WordPress. 193 | * 194 | * @since 1.0.0 195 | */ 196 | public function run() { 197 | $this->loader->run(); 198 | } 199 | 200 | /** 201 | * The name of the plugin used to uniquely identify it within the context of 202 | * WordPress and to define internationalization functionality. 203 | * 204 | * @since 1.0.0 205 | * @return string The name of the plugin. 206 | */ 207 | public function get_plugin_name() { 208 | return $this->plugin_name; 209 | } 210 | 211 | /** 212 | * The reference to the class that orchestrates the hooks with the plugin. 213 | * 214 | * @since 1.0.0 215 | * @return Wp_Spwh_Loader Orchestrates the hooks of the plugin. 216 | */ 217 | public function get_loader() { 218 | return $this->loader; 219 | } 220 | 221 | /** 222 | * Retrieve the version number of the plugin. 223 | * 224 | * @since 1.0.0 225 | * @return string The version number of the plugin. 226 | */ 227 | public function get_version() { 228 | return $this->version; 229 | } 230 | 231 | } 232 | -------------------------------------------------------------------------------- /plugins/wp-spwh/includes/index.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Wp_Spwh_Public { 24 | 25 | /** 26 | * The ID of this plugin. 27 | * 28 | * @since 1.0.0 29 | * @access private 30 | * @var string $plugin_name The ID of this plugin. 31 | */ 32 | private $plugin_name; 33 | 34 | /** 35 | * The version of this plugin. 36 | * 37 | * @since 1.0.0 38 | * @access private 39 | * @var string $version The current version of this plugin. 40 | */ 41 | private $version; 42 | 43 | /** 44 | * Initialize the class and set its properties. 45 | * 46 | * @since 1.0.0 47 | * @param string $plugin_name The name of the plugin. 48 | * @param string $version The version of this plugin. 49 | */ 50 | public function __construct( $plugin_name, $version ) { 51 | 52 | $this->plugin_name = $plugin_name; 53 | $this->version = $version; 54 | 55 | } 56 | 57 | /** 58 | * Register the stylesheets for the public-facing side of the site. 59 | * 60 | * @since 1.0.0 61 | */ 62 | public function enqueue_styles() { 63 | 64 | /** 65 | * This function is provided for demonstration purposes only. 66 | * 67 | * An instance of this class should be passed to the run() function 68 | * defined in Wp_Spwh_Loader as all of the hooks are defined 69 | * in that particular class. 70 | * 71 | * The Wp_Spwh_Loader will then create the relationship 72 | * between the defined hooks and the functions defined in this 73 | * class. 74 | */ 75 | 76 | wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-spwh-public.css', array(), $this->version, 'all' ); 77 | 78 | } 79 | 80 | /** 81 | * Register the JavaScript for the public-facing side of the site. 82 | * 83 | * @since 1.0.0 84 | */ 85 | public function enqueue_scripts() { 86 | 87 | /** 88 | * This function is provided for demonstration purposes only. 89 | * 90 | * An instance of this class should be passed to the run() function 91 | * defined in Wp_Spwh_Loader as all of the hooks are defined 92 | * in that particular class. 93 | * 94 | * The Wp_Spwh_Loader will then create the relationship 95 | * between the defined hooks and the functions defined in this 96 | * class. 97 | */ 98 | 99 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-spwh-public.js', array( 'jquery' ), $this->version, false ); 100 | 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /plugins/wp-spwh/public/css/wp-spwh-public.css: -------------------------------------------------------------------------------- 1 | /** 2 | * All of the CSS for your public-facing functionality should be 3 | * included in this file. 4 | */ -------------------------------------------------------------------------------- /plugins/wp-spwh/public/index.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /plugins/wp-spwh/uninstall.php: -------------------------------------------------------------------------------- 1 | run(); 75 | 76 | } 77 | run_wp_spwh(); 78 | -------------------------------------------------------------------------------- /themes/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | WP Headless CMS 9 | 10 | 11 |

You are trying to access an page that is intended to be used only as part of a WP Headless CMS.

12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /themes/wp-headless/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Theme Name: WP Headless CMS 3 | Author: Integris Web 4 | */ 5 | --------------------------------------------------------------------------------