Skip to content

Commit

Permalink
Merge pull request #48 from infinum/development
Browse files Browse the repository at this point in the history
added additional check if file exists
  • Loading branch information
dingo-d authored Feb 6, 2018
2 parents f8bd686 + 1810b56 commit 1e68af0
Show file tree
Hide file tree
Showing 20 changed files with 265 additions and 167 deletions.
9 changes: 8 additions & 1 deletion README-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ _db-import-production-to-staging.sh
```

## wp-config.php
This is project specific configuration that you can tailor according to your project needs.
At the bottom of the `wp-config.php` file before `require_once ABSPATH . 'wp-settings.php';` add this part:

```php
// Include wp config for your project.
require_once( ABSPATH . 'wp-config-project.php' );
```
This is project specific configuration that you can tailor according to your project needs.

And this global variable somewhere before wp-settings and wp-config-project.php. Set what instance you are using.
```php
// Must be set.
// Possible options are develop, staging and production.
define( 'INF_ENV', 'develop' );
```

------------------------------------
1 change: 1 addition & 0 deletions ci-exclude.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/vendor
.git
4 changes: 0 additions & 4 deletions wp-config-project.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* @since 1.0.0
*/

// Must be set.
// Possible options are develop, staging and production.
define( 'INF_ENV', 'develop' );

if ( ! defined( 'INF_ENV' ) ) {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions wp-content/themes/init_theme_name/admin/class-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

/**
* Class Login
*
* Provides method for replacing default wordpress.org link with
* the home page of the clients site.
*/
class Login {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ public function get_assets_version( $filename = null ) {
return false;
}

return filemtime( get_template_directory() . $filename );
$file_location = get_template_directory() . $filename;

if ( ! file_exists( $file_location ) ) {
return;
}

return filemtime( $file_location );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Define the internationalization functionality
*
* Loads and defines the internationalization files for this plugin
* so that it is ready for translation.
*
* @since 2.0.0
* @package init_theme_name
*/

namespace Inf_Theme\Includes;

/**
* Class Internationalization
*/
class Internationalization {

/**
* Global theme name
*
* @var string
*
* @since 2.0.0
*/
protected $theme_name;

/**
* Global theme version
*
* @var string
*
* @since 2.0.0
*/
protected $theme_version;

/**
* Initialize class
*
* @param array $theme_info Load global theme info.
*
* @since 2.0.0
*/
public function __construct( $theme_info = null ) {
$this->theme_name = $theme_info['theme_name'];
$this->theme_version = $theme_info['theme_version'];
}

/**
* Load the plugin text domain for translation.
*
* @since 2.0.0
*/
public function load_theme_textdomain() {
load_theme_textdomain( $this->theme_name, get_template_directory() . '/languages' );
}
}
44 changes: 34 additions & 10 deletions wp-content/themes/init_theme_name/includes/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
namespace Inf_Theme\Includes;

use Inf_Theme\Admin as Admin;
use Inf_Theme\Plugins as Plugins;
use Inf_Theme\Plugins\Acf as Acf;
use Inf_Theme\Theme as Theme;
use Inf_Theme\Theme\Menu as Menu;
use Inf_Theme\Theme\Acf as Acf;
use Inf_Theme\Theme\Utils as Utils;

/**
Expand All @@ -32,6 +33,8 @@ class Main {
* Loader variable for hooks
*
* @var Loader $loader Maintains and registers all hooks for the plugin.
*
* @since 2.0.0
*/
protected $loader;

Expand Down Expand Up @@ -75,6 +78,7 @@ public function __construct() {

$this->load_dependencies();
$this->define_admin_hooks();
$this->define_plugins_hooks();
$this->define_theme_hooks();
}

Expand All @@ -90,6 +94,17 @@ private function load_dependencies() {
$this->loader = new Loader();
}

/**
* Define the locale for this theme for internationalization.
*
* @since 2.0.0
*/
private function set_locale() {
$plugin_i18n = new Internationalization( $this->get_theme_info() );

$this->loader->add_action( 'after_setup_theme', $plugin_i18n, 'load_theme_textdomain' );
}

/**
* Register all of the hooks related to the admin area functionality.
*
Expand All @@ -101,12 +116,12 @@ private function define_admin_hooks() {
$editor = new Admin\Editor( $this->get_theme_info() );
$admin_menus = new Admin\Admin_Menus( $this->get_theme_info() );
$users = new Admin\Users( $this->get_theme_info() );
$acf = new Admin\Acf( $this->get_theme_info() );

// Admin.
$this->loader->add_action( 'login_enqueue_scripts', $admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_styles', 50 );
$this->loader->add_action( 'admin_body_class', $admin, 'set_enviroment_body_class' );
$this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_scripts' );

// Login page.
$this->loader->add_filter( 'login_headerurl', $login, 'custom_login_url' );
Expand All @@ -121,10 +136,26 @@ private function define_admin_hooks() {
$this->loader->add_action( 'set_user_role', $users, 'send_main_when_user_role_changes', 10, 2 );
$this->loader->add_action( 'admin_init', $users, 'edit_editors_capabilities' );

// ACF.
}

/**
* Register all of the hooks related to the plugins functionality.
*
* @since 2.0.0
*/
private function define_plugins_hooks() {
$acf = new Acf\Acf( $this->get_theme_info() );
$acf_theme_options = new Acf\Theme_Options( $this->get_theme_info() );

// Plugin ACF.
$this->loader->add_action( 'acf/fields/google_map/api', $acf, 'set_google_map_api_key' );
$this->loader->add_action( 'acf/fields/wysiwyg/toolbars', $acf, 'add_wysiwyg_toolbars' );

// Plugin ACF - Theme Options.
$this->loader->add_action( 'acf/init', $acf_theme_options, 'create_theme_options_page' );
$this->loader->add_action( 'acf/init', $acf_theme_options, 'register_theme_options' );
$this->loader->add_action( 'acf/save_post', $acf_theme_options, 'remove_transient' );

}

/**
Expand All @@ -137,7 +168,6 @@ private function define_theme_hooks() {
$legacy_browsers = new Theme\Legacy_Browsers( $this->get_theme_info() );
$widgets = new Theme\Widgets( $this->get_theme_info() );
$menu = new Menu\Menu( $this->get_theme_info() );
$theme_options_general = new Acf\Theme_Options_General( $this->get_theme_info() );
$media = new Theme\Media( $this->get_theme_info() );
$gallery = new Utils\Gallery( $this->get_theme_info() );
$general = new Theme\General( $this->get_theme_info() );
Expand Down Expand Up @@ -177,12 +207,6 @@ private function define_theme_hooks() {
$this->loader->remove_action( 'wp_head', 'feed_links_extra', 3 );
$this->loader->remove_action( 'wp_head', 'rest_output_link_wp_head' );

// Theme Options.
$this->loader->add_action( 'acf/init', $theme_options_general, 'create_theme_options_page' );
$this->loader->add_action( 'acf/init', $theme_options_general, 'register_theme_options' );
$this->loader->add_action( 'acf/init', $theme_options_general, 'register_global_theme_options_variable' );
$this->loader->add_action( 'acf/save_post', $theme_options_general, 'delete_theme_options_transient' );

// Media.
$this->loader->add_action( 'upload_mimes', $media, 'enable_mime_types' );
$this->loader->add_action( 'wp_prepare_attachment_for_js', $media, 'enable_svg_library_preview', 10, 3 );
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions wp-content/themes/init_theme_name/lib/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Inf_Theme\Lib;

spl_autoload_register( __NAMESPACE__ . '\\inf_theme_autoloader' );
spl_autoload_register( __NAMESPACE__ . '\\autoloader' );

/**
* Dynamically loads the class attempting to be instantiated elsewhere in the
Expand All @@ -23,7 +23,7 @@
*
* @since 2.0.0
*/
function inf_theme_autoloader( $class_name ) {
function autoloader( $class_name ) {
$file_path = explode( '\\', $class_name );

if ( isset( $file_path[ count( $file_path ) - 1 ] ) ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?php
/**
* The Advance Custom Field specific functionality.
* The Advance Custom Field plugin specific functionality.
*
* @since 2.0.0
* @package init_theme_name
*/

namespace Inf_Theme\Admin;

use Inf_Theme\Theme\Acf as Acf_Theme;
namespace Inf_Theme\Plugins\Acf;

/**
* Class Advance Custom Fields
Expand Down Expand Up @@ -79,7 +77,7 @@ public function add_wysiwyg_toolbars( $toolbars ) {
*/
public function set_google_map_api_key( $api ) {

$theme_options_general = new Acf_Theme\Theme_Options_General();
$theme_options_general = new Theme_Options();

$api['key'] = $theme_options_general->get_theme_option( 'google_maps_api_key' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package init_theme_name
*/

namespace Inf_Theme\Theme\Acf;
namespace Inf_Theme\Plugins\Acf;

use Inf_Theme\Helpers as General_Helpers;

Expand Down
Loading

0 comments on commit 1e68af0

Please sign in to comment.