daily notes

Advanced WordPress & PHP: Integration & System Snippets External Database Connection Connecting to a database outside of the WordPress installation using the wpdb class. // Create a new database object for an external server $external_db = new wpdb( 'db_user', 'db_password', 'db_name', 'db_host' ); // Query the external DB $results = $external_db->get_results( "SELECT * FROM external_table LIMIT 10" ); // Error checking if ( $external_db->last_error ) { error_log( 'DB Error: ' . $external_db->last_error ); } cURL / Remote Requests (WP_Http) Using the WordPress wrapper for cURL (more secure and handles timeouts/SSL better). ...

January 21, 2026 · 2 min · Ashish Verma

daily notes

WordPress Core Architecture and Request Lifecycle WordPress is a dynamic Content Management System (CMS) powered by PHP and backed by a MySQL or MariaDB database. Understanding the path a request takes from the server to the browser is essential for high-performance development. 1. The Request Pathway When a user accesses a URL on a WordPress site, the following sequence occurs: Initialization: The index.php file in the root directory loads wp-blog-header.php, which subsequently triggers wp-load.php. Configuration: The wp-config.php file is parsed to establish database connections, set memory limits, and define security constants. Core Loading: WordPress loads the core files in wp-includes/, initializes the plugin environment, and then loads the active theme. The Query: The WP_Query class parses the URL to determine what content is being requested (e.g., a single post, a category archive, or a custom post type). Template Hierarchy: WordPress selects the most specific template file available in the theme (e.g., single-post.php before single.php before index.php) based on the Template Hierarchy. The Loop: The selected template executes “The Loop,” fetching data from the database and rendering the HTML output. 2. File and Directory Structure wp-admin/: Contains the administrative dashboard logic. Core files here should never be modified. wp-includes/: The library folder containing the majority of WordPress core functions, classes (like WP_Query, WP_Error), and APIs. wp-content/: The only directory where developers should actively add files. /plugins/: Individual folders for site functionality. /themes/: Folder for the active design and layout templates. /uploads/: Media and file assets. The Hook System: Actions and Filters The “Hook” system is the mechanism that makes WordPress extensible without modifying core files. This is the foundation of professional plugin and theme development. ...

January 20, 2026 · 4 min · Ashish Verma

daily notes

WordPress started as a simple blogging platform but today is used as a CMS as well as an application framework. It can power many things such as eCommerce, LMS (this site), membership sites, communities (social networks), and backend for mobile/decoupled applications. WordPress can be installed using developer tools like EasyEngine, Laravel Valet, Local by Flywheel, Varying Vagrant Vagrants (VVV), and Lando. Layout Toolbar has links to various administration functions, and is displayed at the top of each Administration Screen. Many Toolbar items expand (flyout) when hovered over to display more information. ...

January 19, 2026 · 2 min · Ashish Verma

daily notes

array_key_exists() $data = ['username' => 'Ashish', 'bio' => null]; // array_key_exists returns true because the key 'bio' is present var_dump(array_key_exists('bio', $data)); // Output: bool(true) var_dump() $user = ["id" => 1, "active" => true]; var_dump($user); /* Output: array(2) { ["id"]=> int(1) ["active"]=> bool(true) } */ array_push($stack, "Apple", "Raspberry");: Adds to the end array_unshift(): Adds to the start $result = array_merge($defaults, $userSettings) : merge the arrays Function Declaration function functionName() { } $functionName = function() { }; function functionName ($arg1, $arg2) { } echo: Does not have a return value print: Always returns the integer 1 echo "This ", "is ", "multiple ", "parameters."; // accepts multiple params $result = print "Hello"; // $result is now include: If the file is missing, it generates a Warning (E_WARNING). The script will continue to execute the remaining code. require: If the file is missing, it generates a Fatal Error (E_COMPILE_ERROR). The script will stop immediately. isset() $a = "test"; if (isset($a)) { echo "var set!"; } $_SERVER: Contains information about headers, paths, and script locations. ...

January 16, 2026 · 4 min · Ashish Verma

daily notes

WP-CLI is a PHP-based tool that interacts with your WordPress files and database. It bypasses the web browser, making it significantly faster for repetitive tasks and bulk operations. Task Command List all plugins wp plugin list Install & Activate wp plugin install contact-form-7 --activate Update all plugins wp plugin update --all Deactivate a plugin wp plugin deactivate akismet Export DB: wp db export (creates a .sql file instantly) Import DB: wp db import file.sql ...

January 15, 2026 · 2 min · Ashish Verma

daily notes

WordPress is a free and open-source web content management software (CMS) that can be downloaded and installed on one’s own server. VSCode Extensions Eslint Code runner CSS flexbox cheatsheet Beautify Applications LocalWP brew install composer wget php node Install PHPCS composer global require "squizlabs/php_codesniffer=*" export PATH="$HOME/.composer/vendor/bin:$PATH" Install rules composer global require dealerdirect/phpcodesniffer-composer-installer \ automattic/vipwpcs \ "phpcompatibility/phpcompatibility-wp:*" \ --update-no-dev -W Update composer global update automattic/vipwpcs phpcompatibility/phpcompatibility-wp -W a “Sniff” is a single PHP class that checks one specific coding rule. ...

January 14, 2026 · 2 min · Ashish Verma

daily notes

PHP: Hypertext Preprocessor Runs on the server, not in the browser With PHP you are not limited to output HTML. You can output images or PDF files. You can also output any text, such as XHTML and XML. Install: dnf install php <?php declare(strict_types=1); echo "Hello, PHP\n"; $name = 'Master'; $age = 21; $iStudent = true; $int1 = 012; // => 10 (a leading 0 denotes an octal number) $int4 = 0x0F; // => 15 (a leading 0x denotes a hex literal) $int5 = 0b11111111; // 255 (a leading 0b denotes a binary number) $float = 1.234; $float = 1.2e3; $float = 7E-10; // Delete variable unset($int1); $number += 1; // Shorthand op echo $number++; // increment op // Special characters are only escaped in double quotes $escaped = "This contains a \t tab character."; echo "Age check\n"; if ($age >= 18) { echo "Adult\n"; } else { echo "Minor\n"; } for ($i = 0; $i < 5; $i++) { echo $i; } echo "\n"; function add(int $a, int $b): int { return $a + $b; } echo add(30, 45), "\n"; $nums = [1,2,3,4]; $user = [ "name" => "Master", "role" => "student" ]; class User { public function __construct( public string $name, public string $role ) {} } $user = new User("Master", "Student"); echo $user->name; echo "\n"; // Single line comment # single line comment /* Mulit line comment*/ var_dump(5); var_dump("John"); var_dump(3.14); var_dump(true); ?> PHP script starts with <?php and ends with ?> php basic.php To run a file php -S web.php To start php server ...

January 13, 2026 · 2 min · Ashish Verma