Skip to content

Commit

Permalink
some cool changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stealthcopter committed Feb 15, 2025
1 parent 42059ff commit 9b2ab99
Show file tree
Hide file tree
Showing 13 changed files with 596 additions and 387 deletions.
56 changes: 56 additions & 0 deletions inc/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,61 @@
die( 'not like this...' );
}

function get_all_actions($show_defaults)
{
global $wp_filter;
global $DEFAULT_ACTIONS;
global $DEFAULT_FUNCTIONS;

$defaults = $DEFAULT_ACTIONS['default'];

$ajax_actions = [];

// Loop through the $wp_filter to find all actions
foreach ($wp_filter as $key => $value) {

if (
strpos($key, 'wp_ajax_') !== 0 &&
strpos($key, 'admin_post') !== 0 &&
$key != 'admin_init' &&
$key != 'init'
)
{
continue;
}

if (!$show_defaults && in_array($key, $defaults)) {
continue;
}

foreach ($value->callbacks as $priority => $callbacks) {
foreach ($callbacks as $action => $details) {
if (is_array($details['function']) && isset($details['function'][1])) {
// It's a method inside a class
$class_name = is_object($details['function'][0])
? get_class($details['function'][0])
: $details['function'][0];
$method_name = $details['function'][1];
$full_action_name = $class_name . '::' . $method_name;
} else if (is_string($details['function'])) {
// It's a regular function
$full_action_name = $details['function'];
} else {
$full_action_name = 'unknown_function';
}

if (!$show_defaults && in_array($full_action_name, $DEFAULT_FUNCTIONS['default'])) {
continue;
}

$ajax_actions[md5($key.$full_action_name)] = ["hook"=>$key, "action"=>$full_action_name];
}
}
}

return $ajax_actions;
}

function get_function_code($function_name) {
try {
// Handle class methods
Expand Down Expand Up @@ -63,6 +118,7 @@ function print_code($code_obj, $language='php') {

$mapping = [
'action' => 'Action',
'link' => 'Link',
'route' => 'Route',
'methods' => 'Method(s)',
'parameters' => 'Parameter(s)',
Expand Down
115 changes: 115 additions & 0 deletions inc/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
"wp_ajax_nopriv_woocommerce_get_customer_location",
],
"elementor" => [
"wp_ajax_nopriv_elementor_1_elementor_updater",
"wp_ajax_elementor_1_elementor_updater",
"wp_ajax_elementor_js_log",
"wp_ajax_elementor_clear_cache",
"wp_ajax_elementor_replace_url",
Expand All @@ -185,6 +187,119 @@
]
];

global $DEFAULT_FUNCTIONS;
$DEFAULT_FUNCTIONS = [
"default" =>
[
"create_initial_post_types",
"create_initial_taxonomies",
"WP_Scripts::init",
"wp_widgets_init",
"smilies_init",
"register_core_block_style_handles",
"wp_init_targeted_link_rel_filters",
"_register_core_block_patterns_and_categories",
"wp_cron",
"wp_schedule_delete_old_privacy_export_files",
"_show_post_preview",
"rest_api_init",
"wp_sitemaps_get_server",
"kses_init",
"_wp_footnotes_kses_init",
"wp_register_persisted_preferences_meta",
"wp_create_initial_post_meta",
"wp_schedule_update_checks",
"register_block_core_legacy_widget",
"register_block_core_widget_group",
"register_block_core_archives",
"register_block_core_avatar",
"register_block_core_block",
"register_block_core_calendar",
"register_block_core_categories",
"register_block_core_comment_author_name",
"register_block_core_comment_content",
"register_block_core_comment_date",
"register_block_core_comment_edit_link",
"register_block_core_comment_reply_link",
"register_block_core_comment_template",
"register_block_core_comments",
"register_block_core_comments_pagination",
"register_block_core_comments_pagination_next",
"register_block_core_comments_pagination_numbers",
"register_block_core_comments_pagination_previous",
"register_block_core_comments_title",
"register_block_core_cover",
"register_block_core_file",
"register_block_core_footnotes",
"register_block_core_gallery",
"register_block_core_heading",
"register_block_core_home_link",
"register_block_core_image",
"register_block_core_latest_comments",
"register_block_core_latest_posts",
"register_block_core_loginout",
"register_block_core_navigation",
"register_block_core_navigation_link",
"register_block_core_navigation_submenu",
"register_block_core_page_list",
"register_block_core_page_list_item",
"register_block_core_pattern",
"register_block_core_post_author",
"register_block_core_post_author_biography",
"register_block_core_post_author_name",
"register_block_core_post_comments_form",
"register_block_core_post_content",
"register_block_core_post_date",
"register_block_core_post_excerpt",
"register_block_core_post_featured_image",
"register_block_core_post_navigation_link",
"register_block_core_post_template",
"register_block_core_post_terms",
"register_block_core_post_title",
"register_block_core_query",
"register_block_core_query_no_results",
"register_block_core_query_pagination",
"register_block_core_query_pagination_next",
"register_block_core_query_pagination_numbers",
"register_block_core_query_pagination_previous",
"register_block_core_query_title",
"register_block_core_read_more",
"register_block_core_rss",
"register_block_core_search",
"register_block_core_shortcode",
"register_block_core_site_logo",
"register_block_core_site_tagline",
"register_block_core_site_title",
"register_block_core_social_link",
"register_block_core_tag_cloud",
"register_block_core_template_part",
"register_block_core_term_description",
"register_core_block_types_from_metadata",
"_register_theme_block_patterns",
"init_stealth",
"twentytwentyfour_block_styles",
"twentytwentyfour_block_stylesheets",
"twentytwentyfour_pattern_categories",
"register_legacy_post_comments_block",
"WP_Block_Supports::init",
"check_theme_switched",
"register_admin_color_schemes",
"WP_Privacy_Policy_Content::add_suggested_content",
"wp_schedule_update_user_counts",
"_wp_check_for_scheduled_split_terms",
"_wp_check_for_scheduled_update_comment_type",
"_wp_admin_bar_init",
"_maybe_update_core",
"_maybe_update_plugins",
"_maybe_update_themes",
"wp_admin_headers",
"send_frame_options_header",
"default_password_nag_handler",
"handle_legacy_widget_preview_iframe",
"WP_Privacy_Policy_Content::text_change_check"
]
];

global $DEFAULT_ROUTES;
$DEFAULT_ROUTES = [
'/',
Expand Down
22 changes: 22 additions & 0 deletions inc/init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
session_start(); // Start the session

global $DEFAULT_ACTIONS;
global $DEFAULT_SHORTCODES;
global $DEFAULT_ROUTES;

global $DEFINED_SHORTCODES;
global $DEFINED_ACTIONS;
global $DEFINED_ROUTES;

$show_defaults = get_show_defaults();

$DEFINED_ACTIONS = get_all_actions($show_defaults);
$ACTION_COUNT = count($DEFINED_ACTIONS);

$DEFINED_SHORTCODES = get_shortcodes($DEFAULT_SHORTCODES['default'], $show_defaults);
$SHORTCODE_COUNT = count($DEFINED_SHORTCODES);

$DEFINED_ROUTES = get_rest_routes($DEFAULT_ROUTES, $show_defaults);
$ROUTE_COUNT = count($DEFINED_ROUTES);
$DEFINED_NAMESPACES = get_namespaces();
5 changes: 5 additions & 0 deletions inc/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function is_remote_file($slug){
}

function install_plugin_by_slug($slug) {
$slug = trim($slug);
$output = '';

if (is_remote_file($slug)) {
Expand Down Expand Up @@ -95,6 +96,7 @@ function install_plugin_by_slug($slug) {
}

function activate_plugin_by_slug($slug) {
$slug = trim($slug);
if (is_remote_file($slug)) {
// Installing from URL
$download_link = $slug;
Expand Down Expand Up @@ -130,6 +132,7 @@ function activate_plugin_by_slug($slug) {


function install_theme_by_slug($slug) {
$slug = trim($slug);

if (is_remote_file($slug)) {
// Installing from URL
Expand Down Expand Up @@ -160,6 +163,8 @@ function install_theme_by_slug($slug) {
}

function activate_theme_by_slug($slug) {
$slug = trim($slug);

if (is_remote_file($slug)) {
// Installing from URL
$download_link = $slug;
Expand Down
Loading

0 comments on commit 9b2ab99

Please sign in to comment.