-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from codepress/release/4.0.2
Release/4.0.2
- Loading branch information
Showing
60 changed files
with
41,225 additions
and
1,810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace AC\Controller; | ||
|
||
use AC\Ajax; | ||
use AC\Column\AjaxValue; | ||
use AC\ListScreenRepository\ListScreenRepository; | ||
use AC\Registrable; | ||
|
||
class AjaxColumnValue implements Registrable { | ||
|
||
/** | ||
* @var ListScreenRepository | ||
*/ | ||
private $repository; | ||
|
||
public function __construct( ListScreenRepository $repository ) { | ||
$this->repository = $repository; | ||
} | ||
|
||
public function register() { | ||
$this->get_ajax_handler()->register(); | ||
} | ||
|
||
private function get_ajax_handler() { | ||
$handler = new Ajax\Handler(); | ||
$handler | ||
->set_action( 'ac_get_column_value' ) | ||
->set_callback( [ $this, 'get_value' ] ); | ||
|
||
return $handler; | ||
} | ||
|
||
public function get_value() { | ||
check_ajax_referer( 'ac-ajax' ); | ||
|
||
// Get ID of entry to edit | ||
$id = intval( filter_input( INPUT_POST, 'pk' ) ); | ||
|
||
if ( ! $id ) { | ||
wp_die( __( 'Invalid item ID.', 'codepress-admin-columns' ), null, 400 ); | ||
} | ||
|
||
$list_screen = $this->repository->find( filter_input( INPUT_POST, 'layout' ) ); | ||
|
||
if ( ! $list_screen ) { | ||
wp_die( __( 'Invalid list screen.', 'codepress-admin-columns' ), null, 400 ); | ||
} | ||
|
||
$column = $list_screen->get_column_by_name( filter_input( INPUT_POST, 'column' ) ); | ||
|
||
if ( ! $column ) { | ||
wp_die( __( 'Invalid column.', 'codepress-admin-columns' ), null, 400 ); | ||
} | ||
|
||
if ( ! $column instanceof AjaxValue ) { | ||
wp_die( __( 'Invalid method.', 'codepress-admin-columns' ), null, 400 ); | ||
} | ||
|
||
// Trigger ajax callback | ||
echo $column->get_ajax_value( $id ); | ||
exit; | ||
} | ||
|
||
} |
Oops, something went wrong.