AlkantarClanX12
| Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-careers/app/Admin/ |
| Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-careers/app/Admin/LoadScripts.php |
<?php
namespace Leadbox\Careers\Admin;
use Leadbox\Careers\Traits\Pluggable;
/**
* Ajax request handling for product ordering.
*
* Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/).
* Based on page ordering in Woocommerce by Automattic/Woo (https://en-ca.wordpress.org/plugins/woocommerce/).
*/
class LoadScripts
{
use Pluggable;
public $screenId;
/**
* Callable Class Method
*/
public function __invoke()
{
$this->prep();
$this->handleStyleSheets();
$this->handleCustomPosts();
$this->handleTaxonomy();
}
public function prep()
{
global $wp_query;
$this->query = $wp_query;
$screen = get_current_screen();
$this->screenId = $screen ? $screen->id : '';
}
public function handleStylesheets()
{
wp_enqueue_style( 'leadbox_careers_style', plugins_url() . '/leadbox-careers/resources/styles/admin.css' );
}
/**
* Ajax request handling for product ordering.
*
* Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/).
* Based on page ordering in Woocommerce by Automattic/Woo (https://en-ca.wordpress.org/plugins/woocommerce/).
*/
public function handleCustomPosts()
{
if (! current_user_can( 'edit_others_pages' )) {
return;
}
if ("edit-{$this->plugin->post_type}" !== $this->screenId) {
return;
}
if ( ! isset( $this->query->query['orderby'] )
|| 'menu_order title' !== $this->query->query['orderby']) {
return;
}
wp_register_script( 'leadbox_careers_post_ordering', plugins_url() . '/leadbox-careers/resources/scripts/post-ordering.js', array( 'jquery-ui-sortable' ), $version, true );
wp_enqueue_script( 'leadbox_careers_post_ordering' );
$leadbox_careers_post_order_params = array(
'post_type' => $this->plugin->post_type,
);
wp_localize_script( 'leadbox_careers_post_ordering', 'leadbox_careers_post_ordering_params', $leadbox_careers_post_order_params );
}
/**
* Ajax request handling for product ordering.
*
* Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/).
* Based on page ordering in Woocommerce by Automattic/Woo (https://en-ca.wordpress.org/plugins/woocommerce/).
*/
public function handleTaxonomy()
{
if (isset( $_GET['orderby'] )) {
return;
}
$taxonomy = wp_unslash( $_GET['taxonomy'] ?? '' );
if (! $taxonomy || ! in_array($taxonomy, apply_filters( 'leadbox_careers_sortable_taxonomies', array( 'cdepartments' ) ))) {
return;
}
wp_register_script( 'leadbox_careers_term_ordering', plugins_url() . '/leadbox-careers/resources/scripts/term-ordering.js', array( 'jquery-ui-sortable' ), $version );
wp_enqueue_script( 'leadbox_careers_term_ordering' );
$taxonomy = isset( $_GET['taxonomy'] ) ? $this->clean( wp_unslash( $_GET['taxonomy'] ) ) : '';
$leadbox_careers_term_order_params = array(
'taxonomy' => $taxonomy,
);
wp_localize_script( 'leadbox_careers_term_ordering', 'leadbox_careers_term_ordering_params', $leadbox_careers_term_order_params );
}
public function clean($var)
{
if ( is_array( $var ) ) {
return array_map( [$this, 'clean'], $var );
} else {
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
}
}
}