wordpress

5 Examples to use SHORTINIT in WordPress

The SHORTINIT constant in WordPress is used to perform a minimal bootstrap of the WordPress environment. It’s often used in scenarios where you want to access some core functionality without loading the entire WordPress framework, which can significantly improve performance for certain types of requests. However, it also means that many features of WordPress will not be available. Here’s a typical file structure and some examples of common uses of SHORTINIT in a WordPress plugin. Typical File St[…]

5 Examples to use SHORTINIT in WordPress Read More »

Different to use WP REST API vs Must-Use Plugin (MU Plugin)

Both approaches for handling AJAX requests in WordPress, using the WP REST API and using a Must-Use Plugin (MU Plugin), have their advantages and differences. Here’s a detailed comparison between the two, along with examples and considerations for permission handling. WP REST API The WP REST API is a modern and standardized way to handle AJAX requests. It allows you to create custom endpoints and leverage HTTP methods (GET, POST, etc.) and provides built-in support for authentication and permiss[…]

Different to use WP REST API vs Must-Use Plugin (MU Plugin) Read More »

Usage of wp_add_inline_style and wp_add_inline_script in WordPress

3 regular usages of wp_add_inline_style and wp_add_inline_script Add CSS Style without dependency wp_register_style( ‘wp-juzhax-css’, false ); wp_enqueue_style( ‘wp-juzhax-css’ ); wp_add_inline_style( ‘wp-juzhax-css’, “body *{ box-sizing: inherit; }”); Add JavaScript Code without dependency wp_register_script( ‘wp-juzhax-js-header’, ”,); wp_enqueue_script( ‘wp-juzhax-js-header’ ); wp_add_inline_script( wp-juzhax-js-header’, “console.log(‘loaded in header’);”); Add JavaScript Code with jQuery de[…]

Usage of wp_add_inline_style and wp_add_inline_script in WordPress Read More »

How to modify docker php.ini without installing editor

Editor Not found Recently I would like edit the php.ini in Bitnami WordPress Docker using CLI, but inside the docker doesn’t contain any editor and apt-get is not allowed me to install any editor. $ vim /bin/sh: 1: vim: not found $ vi /bin/sh: 2: vi: not found $ nano /bin/sh: 3: nano: not found $ Modify the upload limit for PHP I want to upload a file more than 800M, I’ve to apply these to php.ini upload_max_filesize 1000M post_max_size 1000M memory_limit 1000M max_execution_time 0 max_input_tim[…]

How to modify docker php.ini without installing editor Read More »

Installing Bitnami WordPress Nginx into Apple m1

Preparing Folders Prepare the a project folders that put your mariadb data and Wordpress files data. # cd ~ # mkdir wp # cd wp # mkdir mariadb # mkdir wordpress The folders we need /Users/juzhax/wp /Users/juzhax/wp/mariadb /Users/juzhax/wp/wordpress Preparing the Docker Compose file touch /Users/juzhax/wp/docker-compose.yml Insert the data using your favorite editor. I like to use vim vim /Users/juzhax/wp/docker-compose.yml version: ‘2’ services: mariadb: image: docker.io/bitnami/mariadb:10.6 vo[…]

Installing Bitnami WordPress Nginx into Apple m1 Read More »

WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Installing Recently I install the Bitnami WordPress for Docker on Apple MacOS with M1 Chip. I followed the documentation from the official Bitnami Wordpress Example console command docker run -d –name wordpress \ -p 8080:8080 -p 8443:8443 \ –env ALLOW_EMPTY_PASSWORD=yes \ –env WORDPRESS_DATABASE_USER=bn_wordpress \ –env WORDPRESS_DATABASE_PASSWORD=bitnami \ –env WORDPRESS_DATABASE_NAME=bitnami_wordpress \ –network wordpress-network \ –volume wordpress_data:/bitnami/wordpress \ bitnami/wor[…]

WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested Read More »

Installing PHP Extension in WP ENV

I need pdo_mysql php extension to use on my Wordpress plugins. After a day of research, I found out that this is the limitation of wp-env. The developers do not want us to touch more to any setting of PHP and Docker. So we have to manually install everytime after wp-env start. You can use this way to install other php extensions. Install pdo_mysql after WP-ENV started. wp-env start docker ps docker exec -it [WORDPRESS_CONTAINER_ID] docker-php-ext-install pdo_mysql docker exec -it [WORDPRESS_CONT[…]

Installing PHP Extension in WP ENV Read More »

WordPress current URL Cheat Sheet

Input https://juzhax.com/page-name/page/3/?query=data Currrent URL with Pagination and Query String $final_url = “{$parts[‘scheme’]}://{$parts[‘host’]}” . add_query_arg( NULL, NULL ); // Result : https://juzhax.com/page-name/page/3/?query=data Current URL without Query String and ending with slash $current_url = home_url( $wp->request ); $final_url = trailingslashit( $current_url ); or $final_url = get_permalink(); or $final_url = get_page_link(); // If it is page. // Result : https://juzhax.[…]

WordPress current URL Cheat Sheet Read More »