### WordPress Configuration and Setup Files (PHP) Source: https://wordpress.org/documentation/wordpress-version/version-5-8 These PHP files are crucial for setting up and configuring a WordPress installation. `wp-config-sample.php` serves as a template for database connection details, while `install.php` guides the initial setup process. ```php ``` -------------------------------- ### WordPress Theme Files (Twenty Nineteen Example) Source: https://wordpress.org/documentation/wordpress-version/version-5-5 This example includes files from the Twenty Nineteen WordPress theme, covering its core PHP template files, customizer options, SVG icon handling, and SASS/CSS for styling. It illustrates theme structure and customization. ```PHP ``` ```SCSS // wp-content/themes/twentynineteen/sass/style.scss // Main SCSS file for Twenty Nineteen theme. @import 'variables'; @import 'mixins/mixins-master'; @import 'site/secondary/widgets'; body { font-family: sans-serif; } ``` ```CSS /* wp-content/themes/twentynineteen/style.css */ /* Main stylesheet for Twenty Nineteen theme */ .site-title { font-size: 2em; } ``` -------------------------------- ### XFN Link Example Source: https://wordpress.org/documentation/article/glossary An example of an XHTML Friends Network (XFN) link. XFN is a way to represent relationships between bloggers using HTML 'rel' attributes. ```html Photo Matt ``` -------------------------------- ### WebVTT Text Track Format Example Source: https://wordpress.org/documentation/article/video-block Example of a WebVTT (Web Video Text Tracks) file format used for displaying timed text tracks like subtitles or captions with video content. This format is essential for accessibility and internationalization. ```text WEBVTT NOTE State of the Word is the annual keynote address celebrating the progress of the open source WordPress project and offering a glimpse into its future. 0:02:14.000 --> 0:02:15.000 Konbanwa 0:02:16.000 --> 0:02:17.000 And howdy. 0:02:18.000 --> 0:02:20.000 And thanks for being here, everyone. ``` -------------------------------- ### Per-Block CSS Example (Hover State for Button Block) Source: https://wordpress.org/documentation/article/styles-overview This example shows how to add a hover effect to the Button block using custom CSS. It illustrates the CSS added within the block's editor, including the use of the ':hover' pseudo-class and curly braces, and the resulting CSS applied on the front end. ```css :hover { background: #bb00bb; } ``` ```css .wp-block-button .wp-block-button__link:hover { background: #bb00bb; } ``` -------------------------------- ### Audio Shortcode with Loop Enabled Source: https://wordpress.org/documentation/article/audio-shortcode This example shows how to enable continuous playback of the audio file. When the audio finishes, it will automatically restart from the beginning. ```plaintext [audio loop="on"] ``` -------------------------------- ### Query String Example (URI) Source: https://wordpress.org/documentation/article/wordpress-glossary Demonstrates a typical query string within a Uniform Resource Identifier (URI). Query strings are used to pass parameters to the web server, often for filtering or searching content, as seen in WordPress. ```URI https://example.com/blog/?category_name=tech&feed=atom ``` -------------------------------- ### WordPress Core Include Files (ID3 Example) Source: https://wordpress.org/documentation/wordpress-version/version-5-5 This snippet lists PHP files from the `wp-includes/ID3` directory, which are part of a library for reading metadata from audio and video files. These files are crucial for WordPress's media handling capabilities. ```PHP ``` -------------------------------- ### Set WordPress and Blog URLs in wp-config.php Source: https://wordpress.org/documentation/wordpress-version/version-2-2 This code demonstrates how to specify the WordPress address (URL) and the Blog address (URL) directly in the wp-config.php file. This is useful for advanced configurations and custom installations. ```php define('WP_SITEURL', 'http://www.sample.com/wordpress'); define('WP_HOME', 'http://www.sample.com'); ``` -------------------------------- ### WordPress Plugin Files (Akismet Example) Source: https://wordpress.org/documentation/wordpress-version/version-5-5 This snippet showcases files related to the Akismet WordPress plugin, including its core PHP logic, CSS for styling, JavaScript for interactivity, and administrative notice views. It demonstrates how plugins extend WordPress functionality. ```PHP ``` ```CSS /* wp-content/plugins/akismet/_inc/akismet.css */ /* Styles for the Akismet plugin */ .akismet-notice { background-color: #f0f0f0; border: 1px solid #ddd; padding: 15px; margin-bottom: 20px; } ``` -------------------------------- ### WordPress Core Include Files (SimplePie Example) Source: https://wordpress.org/documentation/wordpress-version/version-5-5 This snippet shows PHP files from the `wp-includes/SimplePie` directory, which is an RSS and Atom feed fetching and parsing library. It's used in WordPress for features like the RSS widget and importing feeds. ```PHP ``` -------------------------------- ### WordPress Block Stylesheets Source: https://wordpress.org/documentation/wordpress-version/version-6-3 Showcases example CSS files for WordPress blocks, specifically the 'button' block. This includes editor-specific styles and front-end styles, with variations for RTL (right-to-left) languages. ```css /* wp-includes/blocks/button/editor.css */ .wp-block-button__link { /* editor styles */ } ``` ```css /* wp-includes/blocks/button/style.css */ .wp-block-button__link { /* front-end styles */ } ``` ```css /* wp-includes/blocks/button/editor-rtl.css */ .wp-block-button__link { /* editor styles for RTL */ } ``` -------------------------------- ### WordPress Excerpt Display Example (PHP) Source: https://wordpress.org/documentation/article/write-posts-classic-editor This PHP code snippet demonstrates how to display the post excerpt instead of the full content in WordPress theme templates. It relies on the `the_excerpt()` function, which automatically uses the first 55 words or content before the `` tag, or the content from the 'Excerpt' field if provided. ```php ``` -------------------------------- ### Audio Shortcode with Specific MP3 Source Source: https://wordpress.org/documentation/article/audio-shortcode This example demonstrates how to specify the source URL for an MP3 audio file directly within the shortcode. This is useful for linking to audio files in the Media Library or external sources. ```plaintext [audio src="audio-source.mp3"] ``` -------------------------------- ### WordPress Theme Functions Source: https://wordpress.org/documentation/wordpress-version/version-6-0 Core PHP files for WordPress themes that handle theme setup, template tags, and custom functionalities. These files extend WordPress's default behavior. ```php ``` ```php ``` -------------------------------- ### Compare WordPress File Changes with SVN Source: https://wordpress.org/documentation/article/faq-my-site-was-hacked This command-line utility allows users to compare local WordPress files with versions stored in the official WordPress repository using Subversion (SVN). It helps identify modifications and potential security issues. No external dependencies are required if SVN is installed. ```bash svn diff . ``` ```bash svn diff /path/to/filename ``` -------------------------------- ### WordPress Block Editor Assets Source: https://wordpress.org/documentation/wordpress-version/version-6-3 Provides examples of asset files for WordPress blocks, specifically focusing on the 'file' block. This includes JavaScript files for view functionality and their corresponding asset definition files, crucial for block editor integration. ```javascript // wp-includes/blocks/file/view.js (function() { // ... file block view logic ... })(); ``` ```php // wp-includes/blocks/file/view.asset.php [], 'version' => '...', ]; ``` -------------------------------- ### Complex Queries with Meta, Date, and Term in WordPress Source: https://wordpress.org/documentation/wordpress-version/version-4-1 This example shows how to construct complex queries in WordPress using meta, date, and term parameters. It supports advanced conditional logic, including nested clauses and multiple operators (e.g., A OR (B AND C)). This is useful for retrieving specific posts based on intricate criteria. ```php $args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'color', 'value' => 'blue', 'compare' => '=' ), array( 'key' => 'size', 'value' => array('large', 'medium'), 'compare' => 'IN' ) ) ); $query = new WP_Query( $args ); ``` -------------------------------- ### Enable WordPress Multisite (PHP) Source: https://wordpress.org/documentation/article/tools-network-screen This code snippet enables the multisite functionality in WordPress by defining a constant in the wp-config.php file. This action makes the Network menu appear in the Tools section, allowing further configuration. ```php define('WP_ALLOW_MULTISITE', true); ``` -------------------------------- ### Package Management Files (JSON) Source: https://wordpress.org/documentation/wordpress-version/version-5-6-1 This snippet includes package management configuration files for a project, typically used with Node.js and npm. 'package.json' defines project metadata and dependencies, while 'package-lock.json' records the exact versions of installed dependencies. ```json package-lock.json package.json ``` -------------------------------- ### WordPress Initialization and Settings Source: https://wordpress.org/documentation/wordpress-version/version-5-8 This snippet includes core PHP files responsible for WordPress initialization, loading, and settings. `wp-load.php` bootstraps the WordPress environment, `wp-login.php` handles user authentication, `wp-settings.php` sets up core configurations, and `wp-signup.php` manages the user registration process. ```php wp-load.php wp-login.php wp-settings.php wp-signup.php ``` -------------------------------- ### Add WordPress Multisite Authentication Keys to wp-config.php Source: https://wordpress.org/documentation/article/tools-network-screen Includes unique security keys for authentication in wp-config.php to enhance installation security. These keys should be automatically generated and unique to your installation. ```php define( 'AUTH_KEY', '{K 2rUF&uy(Ak0(M3J%f(W&ADLiI(+#^W*H|0@jdAc(0LHOz3)gaiOoDgN_;W+2' ); define( 'SECURE_AUTH_KEY', ']n+=#}^=3BdTn~FoS@8K#o|~WgC@#?Oj*s[L+Y+tInaOjNCFa1h59vRL#!R[[{UI' ); define( 'LOGGED_IN_KEY', 'hFe,fw?jgX@@X,Yl]jz9!qoD]v8N[TNDvleEaE5zH=|`D+yUYM|>/=8KRelv=XPE' ); define( 'NONCE_KEY', 'fkrSg(v-|/&=TC{66rgrX[_VpWv$.{a{q$CvjvjB$AP<5q?|58{6xvN{xut r?|j' ); define( 'AUTH_SALT', 'kVVt8^+oh,$|?g RxaWq_Px RwC%^^r?8zhQ+GDUWp:QB]W!tPHins]RJ@a%P_ue' ); define( 'SECURE_AUTH_SALT','>|tv)^94YuNk[:+)l<5ubJ0uTdo3gn9|YN.0J/MR1R>T=oe1}eov*ds@Z.&PA%&q' ); define( 'LOGGED_IN_SALT', 'E,C#!\n'; } ?> ``` -------------------------------- ### Insecure Site Configuration with wp-admin Redirect (Apache) Source: https://wordpress.org/documentation/article/why-should-i-use-https An example Apache virtual host configuration for an insecure site. It sets the DocumentRoot and includes rewrite rules to redirect requests for wp-admin to the secure domain. This configuration is designed to work with the secure host setup. ```apache ServerName www.mysite.com DocumentRoot /var/www/ii/mysite RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^wp-admin/(.*) https://www.example.com/wp-admin/$1 [C] RewriteRule ^.*$ - [S=40] RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L] ``` -------------------------------- ### Install Symbola Font on Fedora Source: https://wordpress.org/documentation/article/what-are-emoji This command installs the Symbola font package on Fedora systems, enabling emoji display in Linux applications. ```bash sudo yum install gdouros-symbola-fonts ``` -------------------------------- ### Install Symbola Font on Arch Linux Source: https://wordpress.org/documentation/article/what-are-emoji This command installs the Symbola font package on Arch Linux and its derivatives, which is necessary for displaying emoji in Linux applications. ```bash sudo pacman -S ttf-symbola ``` -------------------------------- ### PHP for Theme Install Style Fixes Source: https://wordpress.org/documentation/wordpress-version/version-4-1 This PHP code addresses several styling issues in the theme installation interface. It adjusts the positioning of strings, spacing, and button heights to improve the visual presentation, especially on mobile devices. ```php /** * Theme Install Style Fixes * These are typically handled in CSS, but this illustrates potential PHP hooks if needed. */ // Example: Adjusting 'based on' string position might involve modifying template parts or using filters. // For spacing, CSS is the primary method. // For button height on mobile, CSS media queries are used. ``` -------------------------------- ### WordPress Theme Readme and Style Files Source: https://wordpress.org/documentation/wordpress-version/version-5-2 This snippet includes standard theme files like README.txt for theme information and style.css for basic theme styling. These are common across many WordPress themes. ```text // wp-content/themes/twentyeleven/readme.txt // wp-content/themes/twentyfifteen/readme.txt // wp-content/themes/twentyfourteen/readme.txt ``` ```css // wp-content/themes/twentyeleven/style.css // wp-content/themes/twentyfifteen/style.css // wp-content/themes/twentyfourteen/style.css ``` -------------------------------- ### Open All Links in New Window using HTML Base Tag Source: https://wordpress.org/documentation/article/faq-work-with-wordpress Insert the `` tag within the `` section of your theme's `header.php` file to make all links on your website open in a new browser window. ```html ``` -------------------------------- ### WordPress REST API - Core Controllers Source: https://wordpress.org/documentation/wordpress-version/version-5-6 This section details the core controllers available in the WordPress REST API, which manage different types of data within a WordPress installation. ```APIDOC ## WordPress REST API - Core Controllers ### Description This section details the core controllers available in the WordPress REST API, which manage different types of data within a WordPress installation. ### Endpoints - `/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php`: Manages attachment data. - `/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php`: Manages autosave data. - `/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php`: Manages the block directory. - `/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php`: Renders blocks. - `/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php`: Manages block types. - `/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php`: Manages comment data. - `/wp-includes/rest-api/endpoints/class-wp-rest-controller.php`: Base controller class. - `/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php`: Manages post type data. - `/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php`: Manages post data. - `/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php`: Manages post revision data. - `/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php`: Handles search requests. - `/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php`: Manages term data (categories, tags, etc.). - `/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php`: Manages theme data. - `/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php`: Manages user data. ### Related Files - `/wp-includes/rest-api.php`: Core REST API functionalities. - `/wp-includes/rest-api/class-wp-rest-request.php`: Handles REST API requests. - `/wp-includes/rest-api/class-wp-rest-response.php`: Handles REST API responses. - `/wp-includes/rest-api/class-wp-rest-server.php`: The REST API server implementation. - `/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php`: Handles meta fields in the REST API. - `/wp-includes/rest-api/search/class-wp-rest-search-handler.php`: Handles search within the REST API. ``` -------------------------------- ### WordPress Stylelint Configuration Files Source: https://wordpress.org/documentation/wordpress-version/version-5-8 These JSON files configure Stylelint, a powerful, free, and open-source tool that helps you enforce consistent styles in your CSS, SCSS, and other stylesheet languages. They define linting rules and configurations for the project. ```json { "extends": "@wordpress/stylelint-config", "rules": { "no-descending-specificity": null } } /* wp-content/themes/twentytwentyone/.stylelintrc-css.json */ ``` ```json { "extends": "@wordpress/stylelint-config", "rules": { "no-descending-specificity": null } } /* wp-content/themes/twentytwentyone/.stylelintrc.json */ ``` -------------------------------- ### WordPress Gallery Shortcode with Options Source: https://wordpress.org/documentation/article/the-wordpress-gallery-classic-editor Demonstrates how to add custom options to the WordPress gallery shortcode to control its appearance and behavior. Options are specified as key-value pairs. ```html [gallery option1="value1" option2="value2"] ``` -------------------------------- ### WordPress XML-RPC API - Media Library Source: https://wordpress.org/documentation/wordpress-version/version-3-1 Introduces 'wp.getMediaItem' and 'wp.getMediaLibrary' methods for retrieving information about media items and the media library. ```APIDOC ## POST /xmlrpc.php ### Description Provides methods for interacting with WordPress, including retrieving media items and the media library. ### Method POST ### Endpoint /xmlrpc.php ### Parameters #### Request Body - **method** (string) - Required - The name of the method to call (e.g., 'wp.getMediaItem', 'wp.getMediaLibrary'). - **params** (array) - Required - An array of parameters for the method. ### Request Example (wp.getMediaItem) ```json { "method": "wp.getMediaItem", "params": [1, "username", "password", "media_id"] } ``` ### Request Example (wp.getMediaLibrary) ```json { "method": "wp.getMediaLibrary", "params": [1, "username", "password", {"number": 10}] } ``` ### Response #### Success Response (200) for wp.getMediaItem - **result** (object) - Details of the media item. - **id** (string) - The media item ID. - **url** (string) - The URL of the media item. - **type** (string) - The MIME type of the media item. #### Success Response (200) for wp.getMediaLibrary - **result** (array) - An array of media items. - **id** (string) - The media item ID. - **url** (string) - The URL of the media item. - **type** (string) - The MIME type of the media item. #### Response Example (wp.getMediaItem) ```json { "result": { "id": "123", "url": "http://example.com/wp-content/uploads/image.jpg", "type": "image/jpeg" } } ``` #### Response Example (wp.getMediaLibrary) ```json { "result": [ { "id": "123", "url": "http://example.com/wp-content/uploads/image.jpg", "type": "image/jpeg" }, { "id": "124", "url": "http://example.com/wp-content/uploads/document.pdf", "type": "application/pdf" } ] } ``` ``` -------------------------------- ### WordPress Filesystem Abstraction Classes (PHP) Source: https://wordpress.org/documentation/wordpress-version/version-5-3 This snippet includes classes that form the WordPress Filesystem API, enabling consistent file operations across different hosting environments. It covers base classes and specific implementations for direct, FTP, and SSH2 access. ```php ``` -------------------------------- ### Remove Translations on Theme/Plugin Deletion (PHP) Source: https://wordpress.org/documentation/wordpress-version/version-4-1 Automates the removal of associated translation files when a theme or plugin is deleted. This helps in keeping the WordPress installation clean and organized. ```PHP function remove_translations_on_delete( $item_path, $deleted_item_path ) { // Logic to find and delete .mo and .po files related to the deleted theme or plugin. // Example: glob( WP_LANG_DIR . '/themes/' . basename( $item_path ) . '-*.mo' ); } add_action( 'delete_theme', 'remove_translations_on_delete', 10, 2 ); add_action( 'delete_plugin', 'remove_translations_on_delete', 10, 2 ); ``` -------------------------------- ### WordPress Core Classes Documentation (PHP) Source: https://wordpress.org/documentation/wordpress-version/version-6-1 Documentation for various core WordPress classes, each responsible for specific functionalities like database management (WPDB), query handling (WP_Query), user management (WP_User), and more. These classes form the backbone of WordPress operations. ```php 'post', 'posts_per_page' => 5 ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // Display post title, content, etc. the_title(); } wp_reset_postdata(); } else { // No posts found } // Example: WPDB class for database interaction global $wpdb; $results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_name = 'blogname'" ); if ( $results ) { echo 'Blog Name: ' . $results[0]->option_value; } // Example: WP_Error class for error handling function my_function_that_might_fail() { if ( /* some error condition */ false ) { return new WP_Error( 'error_code', 'An error occurred.' ); } return true; } $result = my_function_that_might_fail(); if ( is_wp_error( $result ) ) { echo 'Error: ' . $result->get_error_message(); } else { // Success } ?> ``` -------------------------------- ### WordPress Theme Functions (PHP) Source: https://wordpress.org/documentation/wordpress-version/version-5-2 These PHP files contain theme-specific functions that extend WordPress's core functionality. They often include theme setup, customizer options, and template tag modifications. ```php __( 'Primary Menu', 'twentytwelve' ), ) ); } add_action( 'after_setup_theme', 'twentytwelve_setup' ); ``` -------------------------------- ### Load Plugin and Theme Translations in WordPress Source: https://wordpress.org/documentation/wordpress-version/version-4-6 Demonstrates how to load translations for plugins and themes in WordPress using `load_plugin_textdomain()` and `load_theme_textdomain()`. It prioritizes loading from the `wp-content/languages` directory before checking the plugin/theme folder. ```php ``` -------------------------------- ### WordPress Package Management Files Source: https://wordpress.org/documentation/wordpress-version/version-5-8 These files, package.json and package-lock.json, are used for managing project dependencies and scripts, typically for JavaScript development tools. They define project metadata, scripts, and the exact versions of installed packages. ```json { "name": "twentytwenty", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" } /* wp-content/themes/twentytwenty/package.json */ ``` ```json // wp-content/themes/twentytwenty/package-lock.json // Lock file for npm package versions ``` ```json { "name": "twentytwentyone", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" } /* wp-content/themes/twentytwentyone/package.json */ ``` ```json // wp-content/themes/twentytwentyone/package-lock.json // Lock file for npm package versions ``` -------------------------------- ### jQuery Core and Utility JavaScript Source: https://wordpress.org/documentation/wordpress-version/version-6-0 This category includes core jQuery library extensions and utility scripts that enhance jQuery's functionality. Examples include color animations, form handling, and query string manipulation. ```javascript wp-includes/js/jquery/jquery.color.min.js wp-includes/js/jquery/jquery.form.min.js wp-includes/js/jquery/jquery.query.js ``` -------------------------------- ### Structure for Splitting WXR Files Source: https://wordpress.org/documentation/article/faq-work-with-wordpress Provides the XML structure for the header and footer of a WordPress WXR file, which can be used to manually split large files into smaller, manageable pieces for import. ```xml including all info like category, tags, etc to just before the first ``` ```xml ``` -------------------------------- ### Enable Unfiltered Uploads in WordPress Source: https://wordpress.org/documentation/article/roles-and-capabilities This code snippet defines a constant to enable unfiltered uploads. When defined as true, all roles on a single site can be given the unfiltered_upload capability. On a Multisite install, only Super Admins can be granted this capability. ```php define( 'ALLOW_UNFILTERED_UPLOADS', true ); ``` -------------------------------- ### Configure WordPress Multisite in wp-config.php Source: https://wordpress.org/documentation/article/tools-network-screen Adds essential constants to wp-config.php to enable multisite functionality and define site parameters. Ensure these are placed above the 'stop editing' line. ```php define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', true ); $base = '/'; define( 'DOMAIN_CURRENT_SITE', 'sample.com' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( 'BLOG_ID_CURRENT_SITE', 1 ); ``` -------------------------------- ### WordPress Gallery Shortcode Customizing Markup Tags Source: https://wordpress.org/documentation/article/the-wordpress-gallery-classic-editor Allows customization of the HTML tags used for gallery items, icons, and captions. This example changes the default 'dl', 'dt', 'dd' tags to 'div', 'span', and 'p' respectively. ```html [gallery itemtag="div" icontag="span" captiontag="p"] ``` -------------------------------- ### WordPress Image Editor (Imagick) Source: https://wordpress.org/documentation/wordpress-version/version-5-8 Handles image editing operations using the Imagick extension. This class provides methods for image manipulation, such as resizing, cropping, and format conversion. It relies on the Imagick PHP extension being installed and enabled. ```php error = new WP_Error( 'image_editor_fail_imagick', __( 'Imagick extension is not available.' ) ); } } /** * Load image from file or data. * * @param string $image */ public function load( $image ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->reset(); $this->image = $image; return true; } /** * Resize image. * * @param int $max_w * @param int $max_h * @param bool $crop */ public function resize( $max_w, $max_h, $crop = false ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $size = $this->get_size(); if ( ! $size ) { return $this->error; } $orig_w = $size['width']; $orig_h = $size['height']; $ratio = $orig_w / $orig_h; if ( $max_w / $max_h > $ratio ) { $new_w = ceil( $max_h * $ratio ); $new_h = $max_h; } else { $new_w = $max_w; $new_h = ceil( $max_w / $ratio ); } if ( $crop ) { $new_w = $max_w; $new_h = $max_h; } $this->image = $this->imagick->resizeImage( $new_w, $new_h, Imagick::FILTER_LANCZOS, 1 ); return true; } /** * Crop image. * * @param int $x1 * @param int $y1 * @param int $x2 * @param int $y2 */ public function crop( $x1, $y1, $x2, $y2 ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->image = $this->imagick->cropImage( $x2 - $x1, $y2 - $y1, $x1, $y1 ); return true; } /** * Rotate image. * * @param int $angle */ public function rotate( $angle ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->image = $this->imagick->rotateImage( $angle ); return true; } /** * Flip image. * * @param bool $horizontal * @param bool $vertical */ public function flip( $horizontal, $vertical = false ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->image = $this->imagick->flipImage( $horizontal, $vertical ); return true; } /** * Get image size. * * @return array|WP_Error */ public function get_size() { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $size = $this->imagick->getImageGeometry(); return array( 'width' => $size['width'], 'height' => $size['height'], ); } /** * Save image. * * @param string $filename * @param string $mime_type */ public function save( $filename, $mime_type = null ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->imagick->setImageFormat( $mime_type ); $this->imagick->writeImage( $filename ); return true; } /** * Get image blob. * * @return string|WP_Error */ public function get_blob() { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } return $this->imagick->getImageBlob(); } /** * Get image mime type. * * @return string|WP_Error */ public function get_mime_type() { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } return $this->imagick->getImageFormat(); } /** * Set image quality. * * @param int $quality */ public function set_quality( $quality ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->imagick->setImageCompressionQuality( $quality ); return true; } /** * Set image format. * * @param string $format */ public function set_format( $format ) { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->imagick->setImageFormat( $format ); return true; } /** * Destroy image object. */ public function destroy() { if ( ! extension_loaded( 'imagick' ) ) { return $this->error; } $this->imagick->destroy(); } } ``` -------------------------------- ### WordPress Theme Files (PHP, SCSS, CSS) Source: https://wordpress.org/documentation/wordpress-version/version-6-1 These files represent the structure and styling for WordPress themes, specifically 'twentytwentyone' and 'twentytwentytwo'. They include template files, CSS stylesheets, SCSS source files for styling, and PHP files for theme-specific functionalities and customizations. ```php // wp-content/themes/twentytwentyone/archive.php // ... archive template ... // wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize-notice-control.php // ... customizer notice control class ... // wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php // ... dark mode class ... // wp-content/themes/twentytwentyone/inc/block-patterns.php // ... block patterns registration ... // wp-content/themes/twentytwentyone/inc/template-tags.php // ... template tags functions ... // wp-content/themes/twentytwentyone/template-parts/footer/footer-widgets.php // ... footer widgets template part ... // wp-content/themes/twentytwentyone/template-parts/header/site-nav.php // ... site navigation template part ... // wp-content/themes/twentytwentyone/template-parts/post/author-bio.php // ... author bio template part ... // wp-content/themes/twentytwentytwo/inc/patterns/footer-dark.php // ... dark footer pattern ... ``` ```scss // wp-content/themes/twentytwentyone/assets/sass/05-blocks/blocks.scss // ... block styling ... // wp-content/themes/twentytwentyone/assets/sass/05-blocks/cover/_editor.scss // ... cover block editor styles ... // wp-content/themes/twentytwentyone/assets/sass/05-blocks/quote/_editor.scss // ... quote block editor styles ... // wp-content/themes/twentytwentyone/assets/sass/05-blocks/utilities/_style.scss // ... block utilities styles ... // wp-content/themes/twentytwentyone/assets/sass/style.scss // ... main theme styles ... ``` ```css // wp-content/themes/twentytwentyone/assets/css/ie-editor.css // ... IE editor specific styles ... // wp-content/themes/twentytwentyone/assets/css/ie.css // ... IE specific styles ... // wp-content/themes/twentytwentyone/assets/css/style-editor.css // ... editor specific styles ... // wp-content/themes/twentytwentyone/style-rtl.css // ... right-to-left styles ... // wp-content/themes/twentytwentyone/style.css // ... main theme stylesheet ... // wp-content/themes/twentytwentytwo/style.css // ... twentytwentytwo theme stylesheet ... ``` ```json // wp-content/themes/twentytwentyone/package-lock.json // ... npm package lock file ... // wp-content/themes/twentytwentyone/package.json // ... npm package configuration ... ``` -------------------------------- ### Audio Shortcode with Autoplay Enabled Source: https://wordpress.org/documentation/article/audio-shortcode This configuration will cause the audio to start playing automatically as soon as the media file is ready to be played. Use with caution to avoid disrupting user experience. ```plaintext [audio autoplay="on"] ``` -------------------------------- ### sodium_compat Namespaced Cryptography Entry Point Source: https://wordpress.org/documentation/wordpress-version/version-5-2 The main entry point for the namespaced cryptography functions within the sodium_compat library. This file likely orchestrates the use of various cryptographic primitives. ```php wp-includes/sodium_compat/namespaced/Crypto.php ``` -------------------------------- ### Twenty Twenty-One Theme Files (PHP, CSS, SCSS, JSON) Source: https://wordpress.org/documentation/wordpress-version/version-6-4 This snippet covers files for the Twenty Twenty-One WordPress theme. It includes PHP files for theme functionality and customization, CSS for styling, SCSS for pre-processing, and JSON for package management. ```PHP // wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php // wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php // wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php // wp-content/themes/twentytwentyone/functions.php // wp-content/themes/twentytwentyone/inc/block-patterns.php // wp-content/themes/twentytwentyone/inc/template-functions.php // Placeholder for Twenty Twenty-One PHP code. function twentytwentyone_setup() { // ... theme setup ... add_theme_support( 'title-tag' ); } add_action( 'after_setup_theme', 'twentytwentyone_setup' ); ``` ```CSS /* wp-content/themes/twentytwentyone/assets/css/ie-editor.css */ /* wp-content/themes/twentytwentyone/assets/css/ie.css */ /* wp-content/themes/twentytwentyone/assets/css/style-editor.css */ /* wp-content/themes/twentytwentyone/style-rtl.css */ /* wp-content/themes/twentytwentyone/style.css */ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; } ``` ```SCSS /* wp-content/themes/twentytwentyone/assets/sass/01-settings/file-header.scss */ /* wp-content/themes/twentytwentyone/assets/sass/05-blocks/quote/_editor.scss */ $primary-color: #0073aa; .site-title { color: $primary-color; } ``` ```JSON // wp-content/themes/twentytwentyone/package-lock.json // wp-content/themes/twentytwentyone/package.json { "name": "twentytwentyone", "version": "1.0.0", "dependencies": { "@wordpress/scripts": "^26.0.0" } } ``` -------------------------------- ### WordPress Filesystem Classes (PHP) Source: https://wordpress.org/documentation/wordpress-version/version-5-9 These PHP classes provide an abstraction layer for interacting with the WordPress filesystem. They support various methods like direct file access, FTP, and SSH2, allowing WordPress to manage files and directories securely and flexibly. ```php