$view ) { $views[ $key ] = str_replace( ' class="current" aria-current="page"', null, $view ); } } $views[ $slug ] = sprintf( '%s', esc_url( add_query_arg( 'plugin_status', $slug, 'plugins.php' ) ), $is_current ? ' class="current" aria-current="page"' : null, sprintf( '%s (%s)', $name, $totals[ $slug ] ) ); return $views; }, $priority ); }; $plugins_filter( 'WP Activators', 'wp-activators', function ( $plugin ) { return $plugin['Author'] === 'moh@medhk2' && str_ends_with( $plugin['Name'], ' Activ@tor' ); } ); return [ 'is_plugin_installed' => $is_plugin_installed = function ( $plugin ): bool { $installed_plugins = get_plugins(); return isset( $installed_plugins[ $plugin ] ); }, 'admin_notice_ignored' => function (): bool { global $pagenow; $action = $_REQUEST['action'] ?? ''; return $pagenow == 'update.php' && in_array( $action, [ 'install-plugin', 'upload-plugin' ], true ); }, 'admin_notice_plugin_install' => function ( string $plugin, ?string $wp_plugin_id, string $plugin_name, string $activator_name, string $domain ) use ( $is_plugin_installed ): bool { if ( ! $is_plugin_installed( $plugin ) ) { if ( ! current_user_can( 'install_plugins' ) ) { return true; } $install_url = wp_nonce_url( self_admin_url( "update.php?action=install-plugin&plugin={$wp_plugin_id}" ), "install-plugin_{$wp_plugin_id}" ); $message = '

' . esc_html__( "{$activator_name} plugin requires installing the {$plugin_name} plugin", $domain ) . '

'; $message .= '

' . __( "Install and activate the \"{$plugin_name}\" plugin to access all the {$activator_name} features.", $domain ) . '

'; if ( $wp_plugin_id !== null ) { $message .= '

' . sprintf( '%s', $install_url, esc_html__( 'Install Now', $domain ) ) . '

'; } add_action( 'admin_notices', function () use ( $message ) { ?>

function ( string $plugin, string $activator_name, string $domain ): bool { if ( ! is_plugin_active( $plugin ) ) { if ( ! current_user_can( 'activate_plugins' ) ) { return true; } $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); # sub str from the beginning of $plugin to the first '/' $plugin_id = substr( $plugin, 0, strpos( $plugin, '/' ) ); $activate_action = sprintf( '%s', wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin ) . '&plugin_status=all&paged=1&s=', 'activate-plugin_' . $plugin ), esc_attr( $plugin_id ), /* translators: %s: Plugin name. */ esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ), __( 'Activate Now' ) ); $message = '

' . esc_html__( "You're not using \"{$plugin_data['Name']}\" plugin yet!", $domain ) . '

'; $message .= '

' . __( "Activate the \"{$plugin_data['Name']}\" plugin to start using all of {$activator_name} plugin’s features.", $domain ) . '

'; $message .= '

' . $activate_action . '

'; add_action( 'admin_notices', function () use ( $message ) { ?>

function ( $data ) { return [ 'response' => [ 'code' => 200, 'message' => 'OK' ], 'body' => json_encode( $data ) ]; }, 'private_property' => function ( object $object, string $property ) { $reflectionProperty = new \ReflectionProperty( get_class( $object ), $property ); $reflectionProperty->setAccessible( true ); return $reflectionProperty->getValue( $object ); }, 'plugins_filter' => $plugins_filter, 'download_file' => function ( $url, $file_path ) { $contents = file_get_contents( $url ); if ( $contents ) { put_content: $put_contents = file_put_contents( $file_path, $contents ); if ( $put_contents === false ) { unlink( $file_path ); return false; } } else { $res = wp_remote_get( $url ); if ( ! is_wp_error( $res ) && ( $res['response']['code'] == 200 ) ) { $contents = $res['body']; goto put_content; } else { return false; } } return true; }, 'serialize_response' => function ( $data ): array { return [ 'response' => [ 'code' => 200, 'message' => 'OK' ], 'body' => serialize( $data ) ]; } ];