Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstandiford committed Nov 23, 2021
2 parents 371a746 + 523d2d4 commit ff23c6d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"underpin/logger-loader": "^2.0"
"underpin/underpin": "^2.0"
},
"autoload": {
"files": [
Expand Down
14 changes: 9 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?php

use Underpin\Abstracts\Underpin;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Add this loader.
add_action( 'underpin/before_setup', function ( $file, $class ) {

Underpin::attach( 'setup', new \Underpin\Factories\Observer( 'widgets', [
'update' => function ( Underpin $plugin, $args ) {
if ( ! defined( 'UNDERPIN_WIDGETS_ROOT_DIR' ) ) {
define( 'UNDERPIN_WIDGETS_ROOT_DIR', plugin_dir_path( __FILE__ ) );
}
require_once( UNDERPIN_WIDGETS_ROOT_DIR . 'lib/abstracts/Widget.php' );
require_once( UNDERPIN_WIDGETS_ROOT_DIR . 'lib/loaders/Widgets.php' );
require_once( UNDERPIN_WIDGETS_ROOT_DIR . 'lib/factories/Widget_Instance.php' );
Underpin\underpin()->get( $file, $class )->loaders()->add( 'widgets', [
'registry' => 'Underpin_Widgets\Loaders\Widgets',
$plugin->loaders()->add( 'widgets', [
'class' => 'Underpin\Widgets\Loaders\Widgets',
] );
}, 10, 2 );
},
] ) );
17 changes: 8 additions & 9 deletions lib/abstracts/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*/


namespace Underpin_Widgets\Abstracts;
namespace Underpin\Widgets\Abstracts;


use Underpin\Abstracts\Settings_Field;
use Underpin\Traits\Feature_Extension;
use Underpin\Traits\Underpin_Templates;
use function Underpin\underpin;
use Underpin\Traits\Underpin\Templates;
use Underpin\Loaders\Logger;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -27,7 +26,7 @@
* @package Underpin\Abstracts
*/
abstract class Widget extends \WP_Widget {
use Underpin_Templates;
use Underpin\Templates;

public $description = '';

Expand All @@ -45,7 +44,7 @@ public function __construct() {
* @inheritDoc
*/
public function widget( $args, $instance ) {
underpin()->logger()->log(
Logger::log(
'error',
'widget_not_set',
'The widget ' . $this->name . ' must extend extend the widget method.'
Expand All @@ -72,7 +71,7 @@ public function form( $instance ) {
$fields = $this->get_fields( $instance );
// If something went wrong, log and return.
if ( is_wp_error( $fields ) ) {
underpin()->logger()->log_wp_error(
Logger::log_wp_error(
'error',
$fields
);
Expand All @@ -96,7 +95,7 @@ public function update( $new, $old ) {

// If something went wrong, log and return.
if ( is_wp_error( $fields ) ) {
underpin()->logger()->log_wp_error(
Logger::log_wp_error(
'error',
$fields
);
Expand All @@ -123,7 +122,7 @@ public function update( $new, $old ) {
}

if ( $errors->has_errors() ) {
underpin()->logger()->log(
Logger::log(
'error',
'failed_to_save_widget_settings',
'Failed to save widget settings',
Expand Down
4 changes: 2 additions & 2 deletions lib/factories/Widget_Instance.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Underpin_Widgets\Factories;
namespace Underpin\Widgets\Factories;


use Underpin\Traits\Instance_Setter;
use Underpin_Widgets\Abstracts\Widget;
use Underpin\Widgets\Abstracts\Widget;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down
15 changes: 8 additions & 7 deletions lib/loaders/Widgets.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

namespace Underpin_Widgets\Loaders;
namespace Underpin\Widgets\Loaders;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

use Underpin\Abstracts\Registries\Loader_Registry;
use Underpin\Abstracts\Registries\Object_Registry;
use Underpin\Loaders\Logger;
use WP_Error;
use WP_Widget;
use function Underpin\underpin;


/**
* Class Widgets
Expand All @@ -18,14 +19,14 @@
* @since 1.0.0
* @package Underpin\Registries\Loaders
*/
class Widgets extends Loader_Registry {
class Widgets extends Object_Registry {

/**
* @inheritDoc
*/
protected $abstraction_class = 'Underpin_Widgets\Abstracts\Widget';
protected $abstraction_class = 'Underpin\Widgets\Abstracts\Widget';

protected $default_factory = 'Underpin_Widgets\Factories\Widget_Instance';
protected $default_factory = 'Underpin\Widgets\Factories\Widget_Instance';

/**
* @inheritDoc
Expand All @@ -42,7 +43,7 @@ public function add( $key, $value ) {
if ( true === $valid ) {
add_action( 'widgets_init', function () use ( $key ) {
register_widget( $this->get( $key ) );
underpin()->logger()->log(
Logger::log(
'notice',
'widget_registered_successfully',
'A widget was Was successfully registered.',
Expand Down
2 changes: 1 addition & 1 deletion templates/widget/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
exit;
}

if ( ! isset( $template ) || ! $template instanceof \Underpin_Widgets\Abstracts\Widget ) {
if ( ! isset( $template ) || ! $template instanceof \Underpin\Widgets\Abstracts\Widget ) {
return;
}

Expand Down

0 comments on commit ff23c6d

Please sign in to comment.