Skip to content

Commit

Permalink
update to core v4.0.71
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindees committed Oct 16, 2019
1 parent f1cb4ac commit 58fca9b
Show file tree
Hide file tree
Showing 20 changed files with 299 additions and 52 deletions.
1 change: 1 addition & 0 deletions admin-configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<p>The <strong>TypeRocket Framework 4</strong> WordPress plugin can be further configured in your <code>wp-config.php</code> file.</p>
<ul>
<li>To disable this page add: <code>define('TR_PLUGIN_ADMIN', false);</code></li>
<li>To disable auto updates: <code>define('TR_UPDATES_OFF', true);</code></li>
<li>You can define your enabled TypeRocket plugins by overriding the <code>tr_plugin_plugins()</code> function.</li>
<li>You can enable the page builder plugin using the <code>define('TR_PLUGIN_PAGE_BUILDER', true);</code> constant.</li>
</ul>
13 changes: 9 additions & 4 deletions typerocket-framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: TypeRocket Framework 4
Plugin URI: https://typerocket.com/
Description: TypeRocket Framework - A WordPress Framework To Empower Your Development
Version: 4.0.14
Version: 4.0.15
Author: Robojuice
Author URI: https://robojuice.com/
License: GPLv3 or later
Expand All @@ -21,17 +21,22 @@ class TypeRocket_Framework {
function __construct()
{
tr_auto_loader();
$updates_off = false;

if( !defined('TR_UPDATES_OFF') ) {
if( defined('TR_UPDATES_OFF') ) {
$updates_off = TR_UPDATES_OFF;
}

if( !$updates_off ) {
new \TypeRocket\Updates\PluginUpdater([
'slug' => 'typerocket-framework',
'api_url' => 'https://typerocket.com/plugins/typerocket-framework/'
'api_url' => 'https://typerocket.com/plugins/typerocket-framework/'
]);
}

$this->path = plugin_dir_path(__FILE__);
define('TR_AUTO_LOADER', '__return_false');
define('TR_PLUGIN_VERSION', '4.0.14');
define('TR_PLUGIN_VERSION', '4.0.15');
register_activation_hook( __FILE__, array($this, 'activation') );
add_action('admin_notices', array($this, 'activation_notice') );
add_action('plugins_loaded', array($this, 'plugins_loaded'));
Expand Down
52 changes: 51 additions & 1 deletion typerocket/vendor/typerocket/core/functions/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ function tr_app( $append ) {
}
}

if( ! function_exists('tr_response') ) {
/**
* Get Main Response
*
* @return \TypeRocket\Http\Response
*/
function tr_response() {
return \TypeRocket\Core\Injector::findOrNewSingleton(\TypeRocket\Http\Response::class);;
}
}

if( ! function_exists('tr_assets_url') ) {
/**
* Get Assets URL
Expand Down Expand Up @@ -813,6 +824,45 @@ function tr_route()
}
}

if ( ! function_exists('tr_routes_repo')) {
/**
* Get Routes Repo
*
* @return \TypeRocket\Http\RouteCollection
*/
function tr_routes_repo()
{
return \TypeRocket\Core\Injector::resolve(\TypeRocket\Http\RouteCollection::class);
}
}

if ( ! function_exists('tr_route_lookup')) {
/**
* Get Routes Repo
* @param string $name
* @return null|\TypeRocket\Http\Route
*/
function tr_route_lookup($name)
{
return tr_routes_repo()->getNamedRoute($name);
}
}

if ( ! function_exists('tr_route_url_lookup')) {
/**
* Get Routes Repo
* @param string $name
* @param array $values
* @param bool $site
*
* @return null|string
*/
function tr_route_url_lookup($name, $values = [], $site = true)
{
return tr_route_lookup($name)->buildUrlFromPattern($values, $site);
}
}

if ( ! function_exists('tr_query')) {
/**
* Database Query
Expand All @@ -830,7 +880,7 @@ function tr_query()
* Http Response
*
* @param string $returned the constant variable name
* @param null|mixed $response The default value
* @param null|\TypeRocket\Http\Response $response The default value
*
* @return mixed
*/
Expand Down
43 changes: 43 additions & 0 deletions typerocket/vendor/typerocket/core/src/Core/Injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,57 @@ public static function resolve($class_name) {
* @param string $class_name
* @param callable $callback
* @param bool $singleton
*
* @return bool
*/
public static function register($class_name, $callback, $singleton = false)
{
if(!empty(self::$list[$class_name])) {
return false;
}

self::$list[$class_name] = [
'callback' => $callback,
'make_singleton' => $singleton,
'singleton_instance' => null
];

return true;
}

/**
* Resolve Singleton
*
* @param string $class_name
*
* @return mixed|null
*/
public static function findOrNewSingleton($class_name)
{
self::register($class_name, function() use ($class_name) {
return new $class_name;
}, true);

return self::resolve($class_name);
}

/**
* Destroy By Key
*
* @param string $class_name
*
* @return bool
*/
public static function destroy($class_name)
{
if(array_key_exists($class_name, self::$list)) {
unset(self::$list[$class_name]['singleton_instance']);
unset(self::$list[$class_name]);

return true;
}

return false;
}

}
10 changes: 10 additions & 0 deletions typerocket/vendor/typerocket/core/src/Database/ResultsMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
namespace TypeRocket\Database;


use TypeRocket\Models\Contract\Formable;

class ResultsMeta extends Results
{
protected $storedValues = [];
Expand Down Expand Up @@ -47,6 +49,14 @@ public function initKeyStore()
return $this->storedValues;
}

/**
* Get Form Fields
*/
public function getFormFields()
{
return $this->storedValues;
}

/**
* Get an attribute from the model.
*
Expand Down
20 changes: 19 additions & 1 deletion typerocket/vendor/typerocket/core/src/Elements/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public function __toString()
return $string;
}

/**
* Set Cast
*
* @param callable $callback
* @param array $args
* @return $this
*/
public function setCast($callback, array $args = [])
{
$this->cast = [
Expand All @@ -83,6 +90,12 @@ public function setCast($callback, array $args = [])
return $this;
}

/**
* Get Cast
*
* @param $value
* @return mixed
*/
public function getCast($value)
{
if( is_array($this->cast) && is_callable($this->cast['callback']) ) {
Expand Down Expand Up @@ -263,7 +276,12 @@ public function getType()
*/
public function setName( $name )
{
$this->name = Sanitize::underscore( $name );
$name_parts = explode('.', strrev($name), 2);
$this->name = Sanitize::underscore( strrev($name_parts[0]) );

if(!empty($name_parts[1])) {
$this->appendToGroup( strrev($name_parts[1]) );
}

return $this;
}
Expand Down
42 changes: 35 additions & 7 deletions typerocket/vendor/typerocket/core/src/Elements/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
namespace TypeRocket\Elements;

use TypeRocket\Core\Config;
use TypeRocket\Core\Injector;
use TypeRocket\Elements\Fields\Submit;
use TypeRocket\Elements\Traits\MacroTrait;
use TypeRocket\Html\Generator;
use TypeRocket\Html\Tag;
use TypeRocket\Elements\Fields\Field;
use TypeRocket\Http\ApplicationRoutes;
use TypeRocket\Http\RouteCollection;
use TypeRocket\Models\WPComment;
use TypeRocket\Models\WPOption;
use TypeRocket\Models\WPPost;
Expand Down Expand Up @@ -37,7 +40,6 @@ class Form
* @param string $action update or create
* @param null|int $itemId you can set this to null or an integer
* @param null|Model|string $model
* @throws \Exception
*/
public function __construct( $resource = 'auto', $action = 'update', $itemId = null, $model = null )
{
Expand All @@ -63,7 +65,6 @@ public function __construct( $resource = 'auto', $action = 'update', $itemId = n
* @param Model|string $model
*
* @return $this
* @throws \Exception
*/
public function setModel( $model )
{
Expand Down Expand Up @@ -227,18 +228,45 @@ public function useJson($resource = null)
*
* @param string $method
* @param string $url
* @param bool $home
*
* @return $this
* @return Form $this
*/
public function useUrl($method, $url)
public function useUrl($method, $url, $home = true)
{
$url_parts = explode('/', trim($url, '/') );
$this->formUrl = home_url(implode('/', $url_parts ) . '/', get_http_protocol() );
$this->method = strtoupper($method);
$this->formUrl = $home ? home_url( trim($url, '/') . '/', get_http_protocol() ) : $url;
$this->method = $method ? strtoupper($method) : $this->method;

return $this;
}

/**
* @param string $name
* @param null|array $values
* @param null|string $method
*
* @return Form
*/
public function useRoute($name, $values = null, $method = null)
{
/** @var ApplicationRoutes $routes */
$routes = Injector::resolve(RouteCollection::class);
$located = $routes->getNamedRoute($name);

$url = $located->buildUrlFromPattern($values ?? $this->model->getProperties());
return $this->useUrl($method, $url, false);
}

/**
* Get Form URL
*
* @return mixed
*/
public function getFormUrl()
{
return $this->formUrl;
}

/**
* To Admin URL
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace TypeRocket\Elements\Traits;

use TypeRocket\Utility\Sanitize;

trait FormConnectorTrait
{

Expand Down Expand Up @@ -90,7 +92,8 @@ public function getGroup()
*/
public function appendToGroup($append)
{
$this->group = $this->group . '.' . $append;
$append = Sanitize::underscore($append, true);
$this->group = $this->group ? $this->group . '.' . $append : $append;

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function setOption( $key, $value )
/**
* Set all options
*
* @param string $options
* @param array $options
* @param string $style options include standard, flat, flip
*
* @return $this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use TypeRocket\Http\Handler;
use \TypeRocket\Http\Request;
use \TypeRocket\Http\Response;

class CommentsResponder extends Responder {

Expand All @@ -18,7 +17,7 @@ public function respond( $args ) {
$controller = tr_app("Controllers\\CommentController");
$controller = apply_filters('tr_comments_responder_controller', $controller);
$request = new Request('PUT', $this->hook);
$response = (new Response())->blockFlash();
$response = tr_response()->blockFlash();

$handler = (new Handler())
->setAction('update')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function respond( $args )
$controller = apply_filters('tr_posts_responder_controller', $controller);

$resource = $registered[0] ?? 'post';
$response = (new Response())->blockFlash();
$response = tr_response()->blockFlash();
$request = new Request('PUT', $this->hook);
$middlewareGroup = [ $resource ,'post'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ResourceResponder extends Responder
public function respond( $args )
{
$request = new Request(null, $this->hook, $this->rest, $this->custom);
$response = new Response();
$response = tr_response();

$handler = (new Handler())
->setAction($this->action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function respond( $args )
$controller = apply_filters('tr_taxonomies_responder_controller', $controller);

$resource = $registered[0] ?? 'category';
$response = (new Response())->blockFlash();
$response = tr_response()->blockFlash();
$request = new Request( 'PUT', $this->hook );
$middlewareGroup = [$resource, 'term', 'category', 'tag'];

Expand Down
Loading

0 comments on commit 58fca9b

Please sign in to comment.