<?php
-/**
- * The base configuration for WordPress
- *
- * The wp-config.php creation script uses this file during the
- * installation. You don't have to use the web site, you can
- * copy this file to "wp-config.php" and fill in the values.
- *
- * This file contains the following configurations:
- *
- * * MySQL settings
- * * Secret keys
- * * Database table prefix
- * * ABSPATH
- *
- * @link https://codex.wordpress.org/Editing_wp-config.php
- *
- * @package WordPress
- */
-
-// ** MySQL settings - You can get this info from your web host ** //
-/** The name of the database for WordPress */
-define('DB_NAME', 'necinitiysnec');
-
-/** MySQL database username */
-define('DB_USER', 'necinitiysnec');
-
-/** MySQL database password */
-define('DB_PASSWORD', 'HARper123');
+// Include local configuration if it exists
+if (file_exists(dirname(__FILE__) . '/local-config.php')) {
+ include(dirname(__FILE__) . '/local-config.php');
+}
-/** MySQL hostname */
-define('DB_HOST', 'necinitiysnec.mysql.db');
+// Global DB config
+if (!defined('DB_NAME')) {
+ define('DB_NAME', 'necinitiysnec');
+}
+if (!defined('DB_USER')) {
+ define('DB_USER', 'necinitiysnec');
+}
+if (!defined('DB_PASSWORD')) {
+ define('DB_PASSWORD', 'HARper123');
+}
+if (!defined('DB_HOST')) {
+ define('DB_HOST', 'necinitiysnec.mysql.db');
+}
/** Database Charset to use in creating database tables. */
-define('DB_CHARSET', 'utf8mb4');
+if (!defined('DB_CHARSET')) {
+ define('DB_CHARSET', 'utf8mb4');
+}
/** The Database Collate type. Don't change this if in doubt. */
-define('DB_COLLATE', '');
+if (!defined('DB_COLLATE')) {
+ define('DB_COLLATE', '');
+}
/**#@+
* Authentication Unique Keys and Salts.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
-define('WP_DEBUG', false);
+if (!defined('WP_DEBUG')) {
+ define('WP_DEBUG', false);
+}
/* That's all, stop editing! Happy blogging. */
--- /dev/null
+<?php
+/*
+Plugin Name: Theme Independent Page Templates
+Plugin URI: http://www.wpexplorer.com/wordpress-page-templates-plugin/
+Description: Allows page templates to be added independent of a theme. Necessary in order to add a page template to Mesmerize PRO theme.
+Version: 1.1.0
+Author: WPExplorer + Cubedesigners
+Author URI: http://www.wpexplorer.com/
+*/
+
+class PageTemplater {
+
+ /**
+ * A reference to an instance of this class.
+ */
+ private static $instance;
+
+ /**
+ * The array of templates that this plugin tracks.
+ */
+ protected $templates;
+
+ /**
+ * Returns an instance of this class.
+ */
+ public static function get_instance() {
+
+ if ( null == self::$instance ) {
+ self::$instance = new PageTemplater();
+ }
+
+ return self::$instance;
+
+ }
+
+ /**
+ * Initializes the plugin by setting filters and administration functions.
+ */
+ private function __construct() {
+
+ $this->templates = array();
+
+
+ // Add a filter to the attributes metabox to inject template into the cache.
+ if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.7', '<' ) ) {
+
+ // 4.6 and older
+ add_filter(
+ 'page_attributes_dropdown_pages_args',
+ array( $this, 'register_project_templates' )
+ );
+
+ } else {
+
+ // Add a filter to the wp 4.7 version attributes metabox
+ add_filter(
+ 'theme_page_templates', array( $this, 'add_new_template' )
+ );
+
+ }
+
+ // Add a filter to the save post to inject out template into the page cache
+ add_filter(
+ 'wp_insert_post_data',
+ array( $this, 'register_project_templates' )
+ );
+
+
+ // Add a filter to the template include to determine if the page has our
+ // template assigned and return it's path
+ add_filter(
+ 'template_include',
+ array( $this, 'view_project_template')
+ );
+
+
+ // Add your templates to this array.
+ $this->templates = array(
+ 'gutenberg-full-width.php' => 'Gutenberg Full Width Page',
+ );
+
+ }
+
+ /**
+ * Adds our template to the page dropdown for v4.7+
+ *
+ */
+ public function add_new_template( $posts_templates ) {
+ $posts_templates = array_merge( $posts_templates, $this->templates );
+ return $posts_templates;
+ }
+
+ /**
+ * Adds our template to the pages cache in order to trick WordPress
+ * into thinking the template file exists where it doens't really exist.
+ */
+ public function register_project_templates( $atts ) {
+
+ // Create the key used for the themes cache
+ $cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );
+
+ // Retrieve the cache list.
+ // If it doesn't exist, or it's empty prepare an array
+ $templates = wp_get_theme()->get_page_templates();
+ if ( empty( $templates ) ) {
+ $templates = array();
+ }
+
+ // New cache, therefore remove the old one
+ wp_cache_delete( $cache_key , 'themes');
+
+ // Now add our template to the list of templates by merging our templates
+ // with the existing templates array from the cache.
+ $templates = array_merge( $templates, $this->templates );
+
+ // Add the modified cache to allow WordPress to pick it up for listing
+ // available templates
+ wp_cache_add( $cache_key, $templates, 'themes', 1800 );
+
+ return $atts;
+
+ }
+
+ /**
+ * Checks if the template is assigned to the page
+ */
+ public function view_project_template( $template ) {
+ // Return the search template if we're searching (instead of the template for the first result)
+ if ( is_search() ) {
+ return $template;
+ }
+
+ // Get global post
+ global $post;
+
+ // Return template if post is empty
+ if ( ! $post ) {
+ return $template;
+ }
+
+ // Return default template if we don't have a custom one defined
+ if ( ! isset( $this->templates[get_post_meta(
+ $post->ID, '_wp_page_template', true
+ )] ) ) {
+ return $template;
+ }
+
+ // Allows filtering of file path (default: ./templates subfolder of theme)
+ $filepath = apply_filters( 'page_templater_plugin_dir_path', plugin_dir_path( __FILE__ ) . 'templates/' );
+
+ $file = $filepath . get_post_meta(
+ $post->ID, '_wp_page_template', true
+ );
+
+ // Just to be safe, we check if the file exist first
+ if ( file_exists( $file ) ) {
+ return $file;
+ } else {
+ echo $file;
+ }
+
+ // Return template
+ return $template;
+
+ }
+
+}
+add_action( 'plugins_loaded', array( 'PageTemplater', 'get_instance' ) );