Skip to content

Commit

Permalink
2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
qstudio committed Dec 19, 2020
1 parent 1bef985 commit 339be05
Show file tree
Hide file tree
Showing 16 changed files with 734 additions and 101 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.0.5 ###

* New: Two view filters added to allow simple extension of custom and native WP templates - willow/view/native + willow/view/custom

### 2.0.4 ###

* Update: Removed extra DI from top level plugin file passing $plugin to sub classes
Expand Down
4 changes: 4 additions & 0 deletions factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public function hooks(){
// prepare filters ##
$this->plugin->set( 'filter_method', new willow\filter\method() );

// build views - required in admin and front-end ##
$view = new willow\view\filter();
$view->hooks();

}

}
2 changes: 1 addition & 1 deletion library/core/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function filter( $args = null, $source = null ) {
$this->template.'__'.$args['context'].'__'.$args['task'] => $this->template.'~'.$args['context'].'~'.$args['task'],

// template/context~task in sub directory ##
// view\is::get().'__'.$args['context'].'__'.$args['task'].'_dir' => view\is::get().'/'.$args['context'].'~'.$args['task'],
// view\method::get().'__'.$args['context'].'__'.$args['task'].'_dir' => view\method::get().'/'.$args['context'].'~'.$args['task'],

// context~task ##
$args['context'].'__'.$args['task'] => $args['context'].'~'.$args['task'],
Expand Down
33 changes: 13 additions & 20 deletions library/core/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
namespace willow\core;

// core ##
use willow;
use willow\plugin as willow;
// use willow;

/**
* helper Class
Expand Down Expand Up @@ -102,7 +103,7 @@ public static function log( $args = null ){
if ( true === \WP_DEBUG ) {

// get caller ##
$backtrace = willow\core\method::backtrace();
$backtrace = \willow\core\method::backtrace();

if ( is_array( $log ) || is_object( $log ) ) {

Expand Down Expand Up @@ -133,7 +134,7 @@ public static function log( $args = null ){
*
* @since 0.1
*/
public function get( $include = null, $return = 'echo', $type = 'url', $path = "library/", $class = null ) {
public static function get( $include = null, $return = 'echo', $type = 'url', $path = "library/", $class = null ) {

// nothing passed ##
if ( is_null( $include ) ) {
Expand All @@ -145,18 +146,10 @@ public function get( $include = null, $return = 'echo', $type = 'url', $path = "
// nada ##
$template = false;

#if ( ! defined( 'TEMPLATEPATH' ) ) {

# w__log( 'MISSING for: '.$include.' - AJAX = '.( \wp_doing_ajax() ? 'true' : 'false' ) );

#}

// w__log( 'd:>h::get class/include: '.$class.'/'.$include );

// perhaps this is a child theme ##
if (
// defined( 'Q_CHILD_THEME' )
// && Q_CHILD_THEME
\get_template_directory() !== \get_stylesheet_directory()
&& file_exists( \get_stylesheet_directory().'/'.$path.$include )
) {
Expand Down Expand Up @@ -184,7 +177,7 @@ public function get( $include = null, $return = 'echo', $type = 'url', $path = "

}

#if ( self::$debug ) self::log( 'parent theme: '.$template );
// w__log( 'parent theme: '.$template );

// load from extended Plugin ##
} elseif (
Expand Down Expand Up @@ -212,42 +205,42 @@ public function get( $include = null, $return = 'echo', $type = 'url', $path = "

// load from Plugin ##
elseif (
file_exists( self::get_plugin_path( $path.$include ) )
file_exists( willow::get_plugin_path( $path.$include ) )
) {

$template = self::get_plugin_url( $path.$include ); // plugin URL ##
$template = willow::get_plugin_url( $path.$include ); // plugin URL ##

if ( 'path' === $type ) {

$template = self::get_plugin_path( $path.$include ); // plugin path ##
$template = willow::get_plugin_path( $path.$include ); // plugin path ##

}

#if ( self::$debug ) self::log( 'plugin: '.$template );
// w__log( 'plugin: '.$template );

}

if ( $template ) { // continue ##

// apply filters ##
$template = \apply_filters( __NAMESPACE__.'_helper_get', $template );
$template = \apply_filters( __NAMESPACE__.'/helper/get', $template );

// echo or return string ##
if ( 'return' === $return ) {

#if ( self::$debug ) w__log( 'returned' );
// w__log( 'returned' );

return $template;

} elseif ( 'require' === $return ) {

#if ( self::$debug ) w__log( 'required' );
// w__log( 'required' );

return require_once( $template );

} else {

#if ( self::$debug ) w__log( 'echoed..' );
// w__log( 'echoed..' );

echo $template;

Expand Down
2 changes: 1 addition & 1 deletion library/get/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function gallery( $args = null ){
|| ! is_array( \get_field( 'media_gallery', $args['post']->ID ) )
) {

w__log( 'd:>Post does not have gallery images' );
// w__log( 'd:>Post does not have gallery images' );

return false;

Expand Down
2 changes: 1 addition & 1 deletion library/get/method.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function prepare_return( $args = null, $array = null ) {
$array = \apply_filters( 'willow/get/'.$method.'/array', $array, $args );

// run template specific filter on $array by $method ##
if ( $template = willow\view\is::get() ) {
if ( $template = willow\view\method::get() ) {

// w__log( 'Filter: "q/ui/get/array/'.$method.'/'.$template.'"' );

Expand Down
8 changes: 7 additions & 1 deletion library/get/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function pagination( $args = null ) {
// args to query WP ##
$paginate_args = [
// 'base' => str_replace( 999999999, '%#%', \esc_url( \get_pagenum_link( 999999999 ) ) ),
'base' => @\add_query_arg('paged','%#%'),
'base' => @\add_query_arg( 'paged','%#%' ),
'format' => '?paged=%#%',
'total' => $total,
'current' => max( 1, \get_query_var( 'paged' ) ),
Expand Down Expand Up @@ -252,6 +252,9 @@ function siblings( $args = null ){
// run query ##
$posts = \get_posts( $wp_args );

// return false, if nothing to show ##
if ( ! $posts ){ return false; }

break ;

case "page" :
Expand All @@ -272,6 +275,9 @@ function siblings( $args = null ){

// get posts ##
$posts = \get_posts( $wp_args );

// return false, if nothing to show ##
if ( ! $posts ){ return false; }

// w__log( $posts );

Expand Down
2 changes: 1 addition & 1 deletion library/render/args.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function assign() {

// apply template level filter to $args - specific calls should be controlled by parameters included directly ##
$_args = $this->plugin->filter->apply([
'filter' => 'willow/render/args/'.\willow\view\is::get(),
'filter' => 'willow/render/args/'.\willow\view\method::get(),
'parameters' => $_args,
'return' => $_args
]);
Expand Down
2 changes: 1 addition & 1 deletion library/view/is.php → library/view/.__is.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function format(){
*/
public static function showing( $file = null ): bool {

// w__log( 'd:>temp: '.view\is::get() );
// w__log( 'd:>temp: '.view\method::get() );
// w__log( 'd:>file: '.$file );

return self::get() == trim( $file ) ;
Expand Down
50 changes: 0 additions & 50 deletions library/view/.__load.php

This file was deleted.

Loading

0 comments on commit 339be05

Please sign in to comment.