DJABHipHop
Forum Replies Created
-
@tinnyfusion @david-innes I’ve made all the columns sortable and add 3 new column 1 accessibility stats, 1 seo stats & one to show for file EXT witch are also sortable as well granted the accessibility & seo status column are no perfect nor sortable yet
// Register custom columns for media library function asenha_add_more_media_columns($columns) { $columns['asenha-media-ext'] = __('Type', 'textdomain'); $columns['seo-status'] = __('SEO', 'textdomain'); $columns['accessibility-status'] = __('Accessibility', 'textdomain'); return $columns; } add_filter('manage_media_columns', 'asenha_add_more_media_columns'); // Populate content for custom columns in media library function asenha_add_more_media_column_content($column_name, $attachment_id) { switch ($column_name) { case 'asenha-media-ext': // Display file extension in uppercase $file_url = wp_get_attachment_url($attachment_id); $filetype = wp_check_filetype($file_url); echo strtoupper($filetype['ext']); break; case 'seo-status': // Check SEO status (alt text and caption) $alt_text = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); $caption = get_post_field('post_excerpt', $attachment_id); if (!empty($alt_text) && !empty($caption)) { // Display green checkmark icon if both alt text and caption are set echo '<span class="dashicons dashicons-yes" style="color: green;"></span>'; } elseif (!empty($alt_text) && empty($caption)) { // Display yellow checkmark icon if either alt text or caption is set echo '<span class="dashicons dashicons-yes" style="color: yellow;"></span>'; } else { // Display red x icon if neither alt text nor caption is set echo '<span class="dashicons dashicons-no" style="color: red;"></span>'; } break; case 'accessibility-status': // Check accessibility status (alt text) $alt_text = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); if (!empty($alt_text)) { // Display green checkmark icon if alt text is set echo '<span class="dashicons dashicons-yes" style="color: green;"></span>'; } else { // Display red x icon if alt text is not set echo '<span class="dashicons dashicons-no" style="color: red;"></span>'; } break; default: // Handle default case (if column name doesn't match any of the above) echo ''; break; } } add_action('manage_media_custom_column', 'asenha_add_more_media_column_content', 10, 2); /** * Make asenha-file-size sortable */ function asenha_make_file_size_columns_sortable($sortable_columns) { $sortable_columns['asenha-file-size'] = 'asenha-file-size'; $sortable_columns['asenha-media-ext'] = 'asenha-media-ext'; $sortable_columns['asenha-id'] = 'asenha-id'; return $sortable_columns; } add_filter('manage_upload_sortable_columns', 'asenha_make_file_size_columns_sortable'); /** * Handle sorting asenha-file-size */ function asenha_sort_media_by_file_size($query) { if (!is_admin() || !$query->is_main_query()) { return; } $orderby = $query->get('orderby'); if ($orderby === 'file_size') { $query->set('meta_key', '_wp_attachment_filesize'); $query->set('orderby', 'meta_value_num'); } if ($orderby === 'id') { $query->set('meta_key', '_wp_attachment_id'); $query->set('orderby', 'meta_value_num'); } if ($orderby === 'ext') { $query->set('meta_key', '_wp_attachment_ext'); $query->set('orderby', 'meta_value_text'); } } add_action('pre_get_posts', 'asenha_sort_media_by_file_size');
Try this code I’ve tested and it works 100%.
/** * Make asenha-file-size sortable */ function asenha_make_file_size_columns_sortable($sortable_columns) { $sortable_columns['asenha-file-size'] = 'asenha-file-size'; return $sortable_columns; } add_filter('manage_upload_sortable_columns', 'asenha_make_file_size_columns_sortable'); /** * Handle sorting asenha-file-size */ function asenha_sort_media_by_file_size($query) { if (!is_admin() || !$query->is_main_query()) { return; } $orderby = $query->get('orderby'); if ($orderby === 'file_size') { $query->set('meta_key', '_wp_attachment_filesize'); $query->set('orderby', 'meta_value_num'); } } add_action('pre_get_posts', 'asenha_sort_media_by_file_size');
Here how it done just replace
universal-theme
with your themes text domaincomments_number( __('0 Comments', 'universal-theme'), __('1 Comments', 'universal-theme'), __('% Comments ', 'universal-theme') );
Skip this line as breaks the back end
add_filter('script_loader_tag', 'add_async_defer', 10, 3);
Forum: Plugins
In reply to: [Simple Basic Contact Form] Not testet with last WP versions?I agree
? ? register_block_pattern( ? ? ? ? 'simple-basic-contact-form', ? ? ? ? array( ? ? ? ? ? ? 'title' => __('Simple Basic Contact Form', 'your-text-domain'), ? ? ? ? ? ? 'description' => __('A block pattern with a single column for the Simple Basic Contact Form plugin shortcode. Requires the Simple Basic Contact Form plugin to be installed and activated.', 'universal-theme'), ? ? ? ? ? ? 'content' => '<!-- wp:columns {"verticalAlignment":"center","isStackedOnMobile":false,"align":"full"} --> ? ? ? ? ? ? ? ? <div class="wp-block-columns alignfull are-vertically-aligned-center is-not-stacked-on-mobile"><!-- wp:column {"verticalAlignment":"center","width":"100%"} --> ? ? ? ? ? ? ? ? <div class="wp-block-column is-vertically-aligned-center" style="flex-basis:100%"><!-- wp:shortcode --> ? ? ? ? ? ? ? ? [simple_contact_form] ? ? ? ? ? ? ? ? <!-- /wp:shortcode --></div> ? ? ? ? ? ? ? ? <!-- /wp:column --></div> ? ? ? ? ? ? ? ? <!-- /wp:columns -->', ? ? ? ? ? ? 'categories'? => array('contact'), ? ? ? ? ) ? ? );
Try this to improve security & increase performance
/** ?* Remove the 'type="text/css"' attribute from stylesheet link tags. ?* ?* @param string $tag The complete HTML tag for the stylesheet. ?* @param string $handle The name of the stylesheet. ?* @param string $src The URL of the stylesheet file. ?* @return string The modified HTML tag for the stylesheet. ?*/ function preload_css($tag, $handle, $src){ ? ? return str_replace('type="text/css"', "", $tag); } add_filter('style_loader_tag', 'preload_css', 10, 3); /** ?* Remove the 'type="text/javascript"' attribute from script link tags. ?* ?* @param string $tag The complete HTML tag for the script. ?* @param string $handle The name of the script. ?* @param string $src The URL of the script file. ?* @return string The modified HTML tag for the script. ?*/ function preload_script($tag, $handle, $src){ ? ? return str_replace('type="text/javascript"', "", $tag); } add_filter('script_loader_tag', 'preload_script', 10, 3); /** ?* Remove query strings from script and style URLs. ?* ?* @param string $src The URL of the script or style. ?* @return string The URL without query strings. ?*/ function wpcode_snippet_remove_query_strings_split($src) { ? ? $output = preg_split( "/(&ver|\\?ver)/", $src ); // Split the URL by '&ver' or '?ver' ? ? return $output ? $output[0] : ''; // Return the URL without query strings } add_filter('script_loader_src', 'wpcode_snippet_remove_query_strings_split', 15); add_filter('style_loader_src', 'wpcode_snippet_remove_query_strings_split', 15); function add_async_defer($tag, $handle, $src) { ? ? return "<script async='async' defer='defer' src='".$src."'></script>"; } add_filter('script_loader_tag', 'add_async_defer', 10, 3);
Forum: Plugins
In reply to: [Admin and Site Enhancements (ASE)] Add plugin Size to plugin list.Both to free
it’s useful to be able plugin size to plugin list to see what plugin are taking up space as in my experience large plugins ten to slow my WordPress installs especially in a dev environment.- This reply was modified 7 months, 2 weeks ago by DJABHipHop.
Forum: Plugins
In reply to: [Admin and Site Enhancements (ASE)] Add plugin Size to plugin list.Both ass to free
- This reply was modified 7 months, 2 weeks ago by DJABHipHop.
- This reply was modified 7 months, 2 weeks ago by DJABHipHop.
Its build in to aes but does not work
- This reply was modified 7 months, 3 weeks ago by DJABHipHop.
Try This
function wpcode_snippet_remove_query_strings_split( $src ) { $output = preg_split( "/(&ver|\\?ver)/", $src ); return $output ? $output[0] : ''; } add_action( 'init', function () { if ( ! is_admin() ) { add_filter( 'script_loader_src', 'wpcode_snippet_remove_query_strings_split', 15 ); add_filter( 'style_loader_src', 'wpcode_snippet_remove_query_strings_split', 15 ); } } );
- This reply was modified 7 months, 4 weeks ago by DJABHipHop.
<?php /* Plugin Name: PHP Memery Stats Plugin URI: Description: This Plugin show how much ram PHP is Usiing Version: 1.0 Author: My Name Author URI: https://example.com/ License: GPLv2 or later */ add_action( 'wp_dashboard_setup', 'memory_usage_setup' ); function memory_usage_setup() { wp_add_dashboard_widget( 'memory_usage-dashboard-widget', 'Memory Usage', 'memory_usage_dashboard_content', $control_callback = null ); } function bytesToSize($bytes, $precision = 2) { $kilobyte = 1024; $megabyte = $kilobyte * 1024; $gigabyte = $megabyte * 1024; $terabyte = $gigabyte * 1024; if (($bytes >= 0) && ($bytes < $kilobyte)) { return $bytes . ' B'; } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { return round($bytes / $kilobyte, $precision) . ' KB'; } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { return round($bytes / $megabyte, $precision) . ' MB'; } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { return round($bytes / $gigabyte, $precision) . ' GB'; } elseif ($bytes >= $terabyte) { return round($bytes / $terabyte, $precision) . ' TB'; } else { return $bytes . ' B'; } } function get_dir_size($directory){ $size = 0; $files= glob($directory.'/*'); foreach($files as $path){ is_file($path) && $size += filesize($path); is_dir($path) && get_dir_size($path); } return $size; } function PluginUrl() { //Try to use WP API if possible, introduced in WP 2.6 if (function_exists('plugins_url')) return trailingslashit(dirname(__FILE__)); //Try to find manually... can't work if wp-content was renamed or is redirected $path = dirname(__FILE__); $path = str_replace("\\","/",$path); $path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/"))); return $path; } function secondsToTime($seconds) { // extract hours $hours = floor($seconds / (60 * 60)); // extract minutes $divisor_for_minutes = $seconds % (60 * 60); $minutes = floor($divisor_for_minutes / 60); // extract the remaining seconds $divisor_for_seconds = $divisor_for_minutes % 60; $seconds = ceil($divisor_for_seconds); // return the final array $obj = array( "h" => (int) $hours, "m" => (int) $minutes, "s" => (int) $seconds, ); return implode(':', $obj); sleep(1); } function get_dir_url($directory,$r="",$s="php-mem/") { return str_replace($s,$r,$directory); } function memory_usage_dashboard_content() { echo '<div id="activity-widget">'; echo '<div id="published-posts" class="activity-block">'; echo "<h4>System Info</h4>"; echo "<ul>"; echo "<li>Operating System <span>".php_uname('s')."</li>"; echo "<li>Release Name <span>".php_uname('r')."</li>"; echo "<li>Version <span>".php_uname('v')."</li>"; echo "<li>Machine Type <span>".php_uname('m')."</li>"; echo "</ul>"; echo "</div>"; echo '<div id="published-posts" class="activity-block">'; echo "<h4>Menory Usage</h4>"; echo "<ul>"; echo "<li>Total ram being used <span>".bytesToSize(memory_get_usage())."</span></li>"; echo "<li>Actule ram being used <span>".bytesToSize(memory_get_peak_usage())."</span></li>"; echo "</ul>"; echo "</div>"; echo '<div id="published-posts" class="activity-block">'; echo "<h4>Disk Space</h4>"; echo "<ul>"; echo "<li>Root directory size <span>".bytesToSize(get_dir_size("./"))."</span></li>"; echo "<li>Plugin directory size <span>".bytesToSize(get_dir_size(get_dir_url(PluginUrl())))."</span></li>"; echo "<li>Uploades directory size <span>".bytesToSize(get_dir_size(get_dir_url(PluginUrl(),"uploads/","plugins/php-mem/")))."</span></li>"; echo "<li>Themes directory size <span>".bytesToSize(get_dir_size(get_dir_url(PluginUrl(),"themes/","plugins/php-mem/")))."</span></li>"; echo "<li>Active Themes directory size <span>".bytesToSize(get_dir_size(get_dir_url(PluginUrl(),"themes/".trailingslashit(get_current_theme()),"plugins/php-mem/")))."</span></li>"; echo "</ul>"; echo "</div>"; echo '<div id="published-posts" class="activity-block">'; echo "<h4>Wordpress Speed</h4>"; echo "<ul>"; echo "<li>Query per second <span>".get_num_queries()." queries in "./*secondsToTime(*/timer_stop(1)/*)*/." seconds</span></li>"; echo "</ul>"; echo "</div>"; echo "</div>"; } ?>
I made one but it old AF below is the full code for those who care
- This reply was modified 7 months, 4 weeks ago by DJABHipHop.
Forum: Plugins
In reply to: [Admin and Site Enhancements (ASE)] Featured Image sizeSWEET!!!!
Forum: Plugins
In reply to: [Admin and Site Enhancements (ASE)] Feature Request : Under Construction modeSWEET!!!!
Forum: Plugins
In reply to: [Admin and Site Enhancements (ASE)] Feature Request: simple ssl optionscool idea