Advanced Web Server Manager
Complete File Manager & Terminal - Standalone Version
By Sid Gifari | Gifari Industries
Current path:
/
/
home
/
qtdcvxyp
/
public_html
/
wp-content
/
plugins
/
pagelayer-pro
/
main
✏️
Editing: abilitiesregister.php
<?php if(!defined('PAGELAYER_PRO_VERSION')) { exit('Hacking Attempt !'); } class Pagelayer_Pro_Abilities_Register { public static function init() { self::register_abilities(); } public static function register_abilities() { // List Theme Templates wp_register_ability('pagelayer-templates/list-theme', array( 'label' => __('List Theme Templates', 'pagelayer'), 'description' => __('List Pagelayer Theme Templates (headers, footers, etc.) with their types and conditions.', 'pagelayer'), 'category' => 'pagelayer-pages', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'type' => array('type' => 'string', 'enum' => array('header', 'footer', 'single', 'archive', 'popup')), ), 'additionalProperties' => false, ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'templates' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'id' => array('type' => 'integer'), 'title' => array('type' => 'string'), 'type' => array('type' => 'string'), 'conditions' => array('type' => 'array', 'items' => array('type' => 'object')), 'edit_url' => array('type' => 'string'), ), ), ), ), ), 'execute_callback' => array(__CLASS__, 'execute_list_theme_templates'), 'permission_callback' => array('Pagelayer_Abilities_Register', 'can_edit_posts'), 'meta' => array('show_in_rest' => true, 'mcp' => array('public' => true)), )); // Create Theme Template wp_register_ability('pagelayer-templates/create-theme', array( 'label' => __('Create Theme Template', 'pagelayer'), 'description' => __('Create a new theme template (header or footer).', 'pagelayer'), 'category' => 'pagelayer-pages', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'title' => array('type' => 'string'), 'type' => array('type' => 'string', 'enum' => array('header', 'footer', 'single', 'archive', 'popup')), 'pagelayer_data' => array('type' => 'object'), 'conditions' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'type' => array('type' => 'string', 'enum' => array('include', 'exclude')), 'template' => array('type' => 'string'), 'sub_template' => array('type' => 'string'), 'id' => array('type' => 'string'), ), 'required' => array('type'), ), ), 'global_colors' => array('type' => 'object', 'description' => __('Key-value map of global colors, e.g. {"primary":{"title":"Primary","value":"#ff007f"}}.', 'pagelayer')), 'global_fonts' => array('type' => 'object', 'description' => __('Key-value map of global fonts.', 'pagelayer')), 'content_width' => array('type' => 'string', 'description' => __('Primary content width, e.g. "1170".', 'pagelayer')), ), 'required' => array('title', 'type'), 'additionalProperties' => false, ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'post_id' => array('type' => 'integer'), 'url' => array('type' => 'string'), 'edit_url' => array('type' => 'string'), ), ), 'execute_callback' => array(__CLASS__, 'execute_create_theme_template'), 'permission_callback' => array('Pagelayer_Abilities_Register', 'can_edit_posts'), 'meta' => array('show_in_rest' => true, 'mcp' => array('public' => true)), )); // Set Theme Conditions wp_register_ability('pagelayer-templates/set-theme-conditions', array( 'label' => __('Set Theme Template Conditions', 'pagelayer'), 'description' => __('Set or update display conditions for a theme template.', 'pagelayer'), 'category' => 'pagelayer-pages', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'post_id' => array('type' => 'integer'), 'conditions' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'type' => array('type' => 'string', 'enum' => array('include', 'exclude')), 'template' => array('type' => 'string'), 'sub_template' => array('type' => 'string'), 'id' => array('type' => 'string'), ), 'required' => array('type'), ), ), ), 'required' => array('post_id', 'conditions'), 'additionalProperties' => false, ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array('type' => 'boolean'), ), ), 'execute_callback' => array(__CLASS__, 'execute_set_theme_conditions'), 'permission_callback' => array('Pagelayer_Abilities_Register', 'can_edit_posts'), 'meta' => array('show_in_rest' => true, 'mcp' => array('public' => true)), )); // Delete Theme Template wp_register_ability('pagelayer-templates/delete-theme', array( 'label' => __('Delete Theme Template', 'pagelayer'), 'description' => __('Delete a theme template from the database.', 'pagelayer'), 'category' => 'pagelayer-pages', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'post_id' => array('type' => 'integer'), 'force' => array('type' => 'boolean', 'default' => false), ), 'required' => array('post_id'), 'additionalProperties' => false, ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array('type' => 'boolean'), ), ), 'execute_callback' => array(__CLASS__, 'execute_delete_theme_template'), 'permission_callback' => array('Pagelayer_Abilities_Register', 'can_edit_posts'), 'meta' => array('show_in_rest' => true, 'mcp' => array('public' => true)), )); } public static function execute_list_theme_templates($input) { $type = isset($input['type']) ? sanitize_text_field($input['type']) : ''; $meta_query = array(); if (!empty($type)) { $meta_query[] = array( 'key' => 'pagelayer_template_type', 'value' => $type, 'compare' => '=', ); } else { $meta_query[] = array( 'key' => 'pagelayer_template_type', 'compare' => 'EXISTS', ); } $query = new \WP_Query(array( 'post_type' => 'pagelayer-template', 'post_status' => array('publish', 'draft'), 'posts_per_page' => -1, 'meta_query' => $meta_query, )); $templates = array(); foreach ($query->posts as $post) { $tmpl_type = get_post_meta($post->ID, 'pagelayer_template_type', true); $conditions = get_post_meta($post->ID, 'pagelayer_template_conditions', true); $templates[] = array( 'id' => $post->ID, 'title' => $post->post_title, 'type' => $tmpl_type, 'conditions' => is_array($conditions) ? $conditions : array(), 'edit_url' => admin_url('post.php?post=' . $post->ID . '&action=edit'), ); } return array('templates' => $templates); } public static function execute_create_theme_template($input) { Pagelayer_Abilities_Register::maybe_update_global_styles($input); $title = sanitize_text_field($input['title']); $type = sanitize_text_field($input['type']); $pagelayer_data = isset($input['pagelayer_data']) ? $input['pagelayer_data'] : array(); $conditions = isset($input['conditions']) ? $input['conditions'] : array( array( 'type' => 'include', 'template' => '', 'sub_template' => '', 'id' => '' ) ); $postarr = array( 'post_title' => $title, 'post_type' => 'pagelayer-template', 'post_status' => 'publish', ); $post_id = wp_insert_post(wp_slash($postarr), true); if (is_wp_error($post_id)) { return $post_id; } update_post_meta($post_id, 'pagelayer_template_type', $type); update_post_meta($post_id, 'pagelayer_template_conditions', $conditions); $normalized_data = Pagelayer_Abilities_Register::normalize_layout_data($pagelayer_data); update_post_meta($post_id, 'pagelayer-data', $normalized_data); $blocks_content = Pagelayer_Abilities_Register::serialize_layout_to_blocks($normalized_data); wp_update_post(array( 'ID' => $post_id, 'post_content' => $blocks_content, )); return array( 'post_id' => $post_id, 'url' => get_permalink($post_id), 'edit_url' => admin_url('post.php?post=' . $post_id . '&action=edit'), ); } public static function execute_set_theme_conditions($input) { $post_id = (int)$input['post_id']; $conditions = $input['conditions']; if (!get_post($post_id) || get_post_type($post_id) !== 'pagelayer-template') { return new \WP_Error('invalid_post', __('Post not found or is not a template.', 'pagelayer')); } update_post_meta($post_id, 'pagelayer_template_conditions', $conditions); return array('success' => true); } public static function execute_delete_theme_template($input) { $post_id = (int)$input['post_id']; $force = !empty($input['force']); if (!get_post($post_id) || get_post_type($post_id) !== 'pagelayer-template') { return new \WP_Error('invalid_post', __('Post not found or is not a template.', 'pagelayer')); } $deleted = wp_delete_post($post_id, $force); return array('success' => (bool)$deleted); } }
💾 Save Changes
❌ Cancel