Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Remove legacy templates #2088

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion future/includes/class-gv-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ private function init() {
require_once $this->plugin->dir( 'future/includes/class-gv-template-view.php' );
require_once $this->plugin->dir( 'future/includes/class-gv-template-entry.php' );
require_once $this->plugin->dir( 'future/includes/class-gv-template-field.php' );
require_once $this->plugin->dir( 'future/includes/class-gv-template-legacy-override.php' );

/** Magic. */
require_once $this->plugin->dir( 'future/includes/class-gv-wrappers.php' );
Expand Down
10 changes: 1 addition & 9 deletions future/includes/class-gv-renderer-entry-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ public function render( Entry $entry, View $view, Request $request = null ) {
$entries = new \GV\Entry_Collection();
$entries->add( $entry );

\GV\Mocks\Legacy_Context::push(
array(
'view' => $view,
'entries' => $entries,
)
);

ob_start();
do_action( 'gravityview_edit_entry', null, $entry, $view, $request );

\GV\Mocks\Legacy_Context::pop();
do_action( 'gravityview_edit_entry', null, $entry, $view, $request );

return ob_get_clean();
}
Expand Down
30 changes: 1 addition & 29 deletions future/includes/class-gv-renderer-entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,7 @@ public function render( Entry $entry, View $view, Request $request = null ) {
$template_slug = apply_filters( 'gravityview_template_slug_' . $view->settings->get( 'template_single_entry' ), 'table', 'single' );

/**
* Load a legacy override template if exists.
*/
$override = new \GV\Legacy_Override_Template( $view, $entry, null, $request );
foreach ( array( 'single' ) as $part ) {
if ( ( $path = $override->get_template_part( $template_slug, $part ) ) && false === strpos( $path, '/deprecated' ) ) {
/**
* We have to bail and call the legacy renderer. Crap!
*/
gravityview()->log->notice( 'Legacy templates detected in theme {path}', array( 'path' => $path ) );

/**
* Show a warning at the top, if View is editable by the user.
*/
add_action( 'gravityview_before', $this->legacy_template_warning( $view, $path ) );

return $override->render( $template_slug );
}
}

/**
* Filter the template class that is about to be used to render the entry.
* Filters the template class that is about to be used to render the entry.
*
* @since 2.0
* @param string $class The chosen class - Default: \GV\Entry_Table_Template.
Expand All @@ -141,14 +121,6 @@ public function render( Entry $entry, View $view, Request $request = null ) {
/** Mock the legacy state for the widgets and whatnot */
$entries = new Entry_Collection();
$entries->add( $entry );
\GV\Mocks\Legacy_Context::push(
array(
'view' => $view,
'entries' => $entries,
'entry' => $entry,
'request' => $request,
)
);

ob_start();
$template->render();
Expand Down
46 changes: 1 addition & 45 deletions future/includes/class-gv-renderer-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,7 @@ public function render( View $view, Request $request = null ) {
}

/**
* Load a legacy override template if exists.
*/
$override = new \GV\Legacy_Override_Template( $view, null, null, $request );
foreach ( array( 'header', 'body', 'footer' ) as $part ) {

$path = $override->get_template_part( $template_slug, $part );

if ( $path && false === strpos( $path, '/deprecated' ) ) {
/**
* We have to bail and call the legacy renderer. Crap!
*/
gravityview()->log->notice( 'Legacy templates detected in theme {path}', array( 'path' => $path ) );

/**
* Show a warning at the top, if View is editable by the user.
*/
add_action( 'gravityview_before', $this->legacy_template_warning( $view, $path ) );

return $override->render( $template_slug );
}
}

/**
* Filter the template class that is about to be used to render the view.
* Filters the template class that is about to be used to render the view.
*
* @since 2.0
* @param string $class The chosen class - Default: \GV\View_Table_Template.
Expand Down Expand Up @@ -178,26 +155,6 @@ public function render( View $view, Request $request = null ) {
/** @todo Deprecate this! */
$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $view->form->ID );

global $post;

/** Mock the legacy state for the widgets and whatnot */
\GV\Mocks\Legacy_Context::push(
array_merge(
array(
'view' => $view,
'entries' => $entries,
'request' => $request,
),
empty( $parameters ) ? array() : array(
'paging' => $parameters['paging'],
'sorting' => $parameters['sorting'],
),
empty( $post ) ? array() : array(
'post' => $post,
)
)
);

add_action(
'gravityview/template/after',
$view_id_output = function ( $context ) {
Expand All @@ -212,7 +169,6 @@ public function render( View $view, Request $request = null ) {
remove_filter( 'gravityview/template/view/render', $add_anchor_id_filter );
remove_filter( 'gravityview/widget/search/form/action', $add_search_action_filter );

\GV\Mocks\Legacy_Context::pop();
return ob_get_clean();
}
}
56 changes: 0 additions & 56 deletions future/includes/class-gv-template-entry-legacy.php

This file was deleted.

1 change: 0 additions & 1 deletion future/includes/class-gv-template-entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,3 @@ public function get_back_label( $do_replace = true ) {
/** Load implementations. */
require gravityview()->plugin->dir( 'future/includes/class-gv-template-entry-table.php' );
require gravityview()->plugin->dir( 'future/includes/class-gv-template-entry-list.php' );
require gravityview()->plugin->dir( 'future/includes/class-gv-template-entry-legacy.php' );
6 changes: 0 additions & 6 deletions future/includes/class-gv-template-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,6 @@ public function render() {
$source = $this->source;
$source_backend = $source ? $source::$backend : null;

\GV\Mocks\Legacy_Context::load(
array(
'field' => $this->field,
)
);

/** Alter the display value according to Gravity Forms. */
if ( \GV\Source::BACKEND_GRAVITYFORMS === $source_backend && ! $this->field instanceof Internal_Field ) {

Expand Down
Loading