Last active
October 22, 2021 05:24
-
-
Save junaidtk/c13c2f86fbd21c3e17a1acab4a23ed80 to your computer and use it in GitHub Desktop.
WordPress Basics Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) is_admin() check and AJAX Call | |
================================= | |
// Is admin, but not doing ajaax | |
if( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { | |
require_once('admin/functions_admin.php'); | |
} | |
// Is doing AJAX | |
else if ( is_admin() && ( defined( 'DOING_AJAX' ) || DOING_AJAX ) ) { | |
require_once('functions_ajax.php'); | |
} | |
// Front-end functions | |
else { | |
require_once('public/functions_public.php'); | |
} | |
2) WordPress debugging: | |
======================= | |
// To enable debug mode. | |
define('WP_DEBUG', true); | |
// To enable the debug logging to debug.log file in wp-content/ | |
define('WP_DEBUG_LOG', true); | |
// To disable the display of errors and warnings | |
define('WP_DEBUG_DISPLAY', false); | |
// To enable the development version of css and js file | |
define('SCRIPT_DEBUG', true); | |
3)How to generate the POT file: | |
=============================== | |
Create a POT file for the WordPress plugin/theme in the current directory | |
$ wp i18n make-pot . languages/my-plugin.pot | |
4) How to increase Max input var | |
================================ | |
Change the php.ini max_input_vars parameter to desired value. | |
max_input_vars =3000 | |
Or Set using .htaccess file. | |
php_value max_input_vars 3000 | |
or Set using wp-config directives. | |
@ini_set( 'max_input_vars' , 4000 ); | |
5) How to increase upload max size: | |
================================== | |
You can change the upload max size in three way. | |
By modifying the php.ini file. | |
upload_max_filesize = 128M | |
post_max_size = 128M | |
max_execution_time = 300 | |
Or | |
By modifying the .htaccess file. | |
php_value upload_max_filesize 128M | |
php_value post_max_size 128M | |
php_value max_execution_time 300 | |
php_value max_input_time 300 | |
Or by using the php ini directives in theme functions.php or wp-config.php. | |
@ini_set( 'upload_max_size' , '128M' ); | |
@ini_set( 'post_max_size', '128M'); | |
@ini_set( 'memory_limit', '256M' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment