<?php
class Xoo_Admin{
public $data = array();
public $tabs = array();
public $sections = array();
public $settings = array();
public $raw_settings = array();
public $tabPriority = 10;
public $helper;
public $settings_slug = '';
public $viewsPath = '';
public $hasPRO = false;
public $capability = 'manage_options';
public function __construct( $helper ){
$this->helper = $helper;
$this->settings_slug = $this->helper->slug . '-settings';
if( is_dir( $this->helper->path .'/admin/views' ) ){
$this->viewsPath = $this->helper->path .'/admin/views';
}
$this->hooks();
}
public function is_settings_page(){
return isset( $_GET['page'] ) && $_GET['page'] === $this->settings_slug;
}
public function hooks(){
add_action( 'wp_ajax_xoo_admin_settings_save', array( $this, 'save_settings' ), 5 );
add_action( 'init', array( $this, 'reset_settings' ) );
add_action( 'init', array( $this, 'save_default_settings' ) );
if( $this->is_settings_page() ){
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts') );
add_action( 'wp_loaded', array( $this, 'set_info_tab' ) );
add_action( 'xoo_tab_page_start', array( $this, 'outdated_template_status_section' ), 10, 2 );
add_action( 'xoo_tab_page_start', array( $this, 'shortcode_info' ), 20, 2 );
}
}
//Add info tab
public function set_info_tab(){
$this->register_tab( 'Info', 'info', '' );
}
public function outdated_template_status_section( $tab_id, $tab_data ){
if( $tab_id !== 'info' ) return;
echo $this->helper->get_outdated_section();
}
public function shortcode_info( $tab_id, $tab_data ){
if( $tab_id !== 'info' || !$this->viewsPath || !file_exists( $this->viewsPath.'/settings/shortcode-info.php' ) ) return;
$args = array(
'shortcodes' => include $this->viewsPath.'/settings/shortcode-info.php'
);
$this->helper->get_template( '/admin/templates/global/info-shortcode.php', $args, XOO_FW_DIR );
}
public function save_default_settings(){
if( !current_user_can( $this->capability ) ) return;
foreach ( $this->settings as $tab_id => $sections ) {
if( !isset( $this->tabs[ $tab_id ][ 'option_key' ] ) ) continue;
$option_key = $this->tabs[ $tab_id ][ 'option_key' ];
$savedOptions = (array) get_option( $option_key, true );
foreach ( $sections as $settings ) {
foreach ( $settings as $setting_id => $setting_data ) {
if( isset( $savedOptions[ $setting_id ] ) ) continue;
$savedOptions[ $setting_id ] = isset( $setting_data['default'] ) ? $setting_data['default'] : '';
}
}
update_option( $option_key, $savedOptions );
}
}
public function reset_settings(){
if( !current_user_can( $this->capability ) ) return;
if( !isset( $_GET['reset'] ) || !isset( $_GET['page'] ) || $this->settings_slug !== $_GET['page'] ) return;
foreach ( $this->settings as $tab_id => $sections ) {
if( !isset( $this->tabs[ $tab_id ][ 'option_key' ] ) ) continue;
update_option( $this->tabs[ $tab_id ][ 'option_key' ], array() );
}
wp_safe_redirect( esc_url( remove_query_arg( 'reset' ) ) );
}
public function save_settings(){
if( !current_user_can( $this->capability ) ) return;
$formData = array();
$parseFormData = parse_str( $_POST['form'], $formData );
foreach ( $formData as $option_key => $option_data ) {
$option_data = stripslashes_deep( $option_data );
update_option( $option_key, $option_data );
}
wp_send_json(array(
'error' => 0,
'notice' => 'Settings Saved',
));
}
public function enqueue_scripts() {
do_action( 'xoo_as_enqueue_scripts', $this->helper->slug );
wp_enqueue_media(); // media gallery
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'xoo-admin-style', XOO_FW_URL . '/admin/assets/css/xoo-admin-style.css', array(), XOO_FW_VERSION, 'all' );
wp_enqueue_script( 'xoo-admin-js', XOO_FW_URL . '/admin/assets/js/xoo-admin-js.js', array( 'jquery','wp-color-picker'), XOO_FW_VERSION, false );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_localize_script( 'xoo-admin-js', 'xoo_admin_params', array(
'adminurl' => admin_url().'admin-ajax.php',
) );
}
public function register_menu_page( $args = array() ){
$args = wp_parse_args( $args, array(
'title' => 'Settings',
'menu_title' => 'Settings',
'capability' => $this->capability,
'slug' => $this->settings_slug,
'callback' => array( $this,'settings_page_markup' ),
'position' => null,
'icon' => '',
'has_submenu' => false,
) );
extract( $args );
add_menu_page(
$title,
$menu_title,
$capability,
$slug,
$callback,
$icon,
$position
);
if( $has_submenu ){
add_submenu_page(
$slug,
'Settings',
'Settings',
$capability,
$slug,
$callback
);
}
}
public function register_as_submenu_page( $args = array() ){
$args = wp_parse_args( $args, array(
'parent_slug' => 'settings',
'title' => 'Settings',
'menu_title' => 'Settings',
'capability' => $this->capability,
'slug' => $this->settings_slug,
'callback' => array( $this,'settings_page_markup' ),
'position' => null,
) );
extract( $args );
add_submenu_page(
$parent_slug,
$title,
$menu_title,
$capability,
$slug,
$callback
);
}
public function register_tab( $title, $id, $option_key = '', $pro = 'no', $args = array() ){
$args = wp_parse_args(
$args,
array(
'priority' => ''
)
);
$priority = $args['priority'];
unset( $args['priority'] );
$this->tabs[ $id ] = array(
'title' => $title,
'id' => $id,
'option_key' => $option_key,
'priority' => $priority,
'pro' => $pro,
'args' => $args
);
}
public function register_section( $title, $id, $tab_id, $desc = '', $pro = 'no', $args = array() ){
$args = wp_parse_args(
$args,
array(
'priority' => ''
)
);
$priority = $args['priority'];
unset( $args['priority'] );
$this->sections[ $tab_id ][ $id ] = array(
'title' => $title,
'id' => $id,
'tab' => $tab_id,
'priority' => $priority,
'desc' => $desc,
'pro' => $pro,
'args' => $args
);
}
public function register_setting( $callback, $title, $id, $section_id, $tab_id, $default = '', $desc = '', $pro = 'no', $args = array() ){
if( !isset( $this->tabs[ $tab_id ] ) || !isset( $this->sections[ $tab_id ][ $section_id ] ) ) return;
if( $pro === "yes" ){
$this->hasPRO = true;
}
$args = wp_parse_args(
$args,
array(
'priority' => ''
)
);
$priority = $args['priority'];
unset( $args['priority'] );
$this->settings[ $tab_id ][ $section_id ][ $id ] = $this->raw_settings[] = array(
'callback' => $callback,
'title' => $title,
'id' => $id,
'section_id' => $section_id,
'tab_id' => $tab_id,
'priority' => $priority ,
'default' => $default,
'desc' => $desc,
'pro' => $pro,
'args' => $args
);
}
protected function sort_by_priority( $data = array() ){
if( !is_array( $data ) || empty( $data ) ) return $data;
uasort( $data, function( $a, $b ){
if( $a['priority'] === $b['priority'] ){
return 0;
}
return $a['priority'] > $b['priority'] ? 1 : -1;
});
return $data;
}
public function sort(){
//Sort Tabs
$this->tabs = $this->sort_by_priority( $this->tabs );
//Sort Section
foreach ( $this->sections as $tab_id => $sections ) {
$priority = 10;
foreach ( $sections as $section_id => $section_data ) {
if( !$section_data['priority'] ){
$this->sections[ $tab_id ][ $section_id ]['priority']
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v3.1.zip
共52个文件
php:39个
css:3个
png:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 120 浏览量
2022-03-29
18:06:57
上传
评论
收藏 111KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v3.1 Xootix Side Cart For WooCommerce Woocommerce的Xootix侧车" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v3.1.zip (52个子文件)
woocommerce-side-cart-premium
admin
templates
xoo-wsc-tab-info.php 0B
class-xoo-wsc-admin-settings.php 2KB
views
sections.php 2KB
tabs.php 453B
settings
style.php 16KB
general.php 10KB
advanced.php 607B
templates
xoo-wsc-header.php 1KB
xoo-wsc-body.php 4KB
xoo-wsc-footer.php 1KB
xoo-wsc-markup.php 818B
xoo-wsc-container.php 2KB
global
slider
calculate-shipping.php 4KB
apply-coupon.php 3KB
inline-style.php 6KB
footer
buttons.php 1KB
suggested-products.php 2KB
totals.php 1KB
extras.php 2KB
body
product.php 3KB
qty-input.php 1KB
header
shipping-bar.php 892B
xoo-wsc-shortcode.php 1KB
xoo-wsc-slider.php 2KB
assets
css
xoo-wsc-fonts.css 3KB
fonts
Woo-Side-Cart.ttf 14KB
Woo-Side-Cart.eot 14KB
Woo-Side-Cart.woff 14KB
Woo-Side-Cart.svg 50KB
xoo-wsc-style.css 15KB
images
arrow-right.png 464B
arrow-left.png 465B
js
xoo-wsc-main.js 23KB
languages
side-cart-woocommerce.pot 4KB
dd.php 0B
wpml-config.xml 511B
includes
class-xoo-wsc-template-args.php 8KB
class-xoo-wsc-frontend.php 5KB
class-xoo-wsc-loader.php 4KB
class-xoo-wsc-cart.php 19KB
xoo-wsc-functions.php 3KB
xoo-framework
class-xoo-exception.php 545B
admin
templates
global
info-shortcode.php 911B
setting-upload.php 397B
xoo-admin-settings-output.php 1KB
assets
css
xoo-admin-style.css 6KB
js
xoo-admin-js.js 4KB
class-xoo-admin-settings.php 19KB
class-xoo-helper.php 9KB
xoo-framework.php 316B
class-xoo-wsc-helper.php 780B
xoo-wsc-main.php 953B
共 52 条
- 1
资源评论
Lee达森
- 粉丝: 962
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功