- XDebug v3+ inside Docker (e.g. php:7.3-apache Docker image)
- Running Docker v20.10+
- VSCode with PHP Debug Extension (Felix Becker)
- Using Docker Compose for orchestration
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
| <?php | |
| // This filter specifically checks whether a theme has a `changelog` template. | |
| // If not, it looks for a fallback template in the plugin. | |
| add_filter( 'template_include', function( $template ) { | |
| // I'm just testing a query string here for demonstration/testing | |
| // purposes, but you'll want to add a check for your registered query | |
| // var with WordPress. For now, you can test with `?changelog=anything`. | |
| if ( ! isset( $_GET['changelog'] ) ) { |
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
| /** | |
| * WordPress dependencies | |
| */ | |
| import { useSelect, dispatch } from '@wordpress/data'; | |
| import { useLayoutEffect } from '@wordpress/element'; | |
| import './store'; | |
| const storeName = 'plugin-name/block'; | |
| function Edit( { attributes, setAttributes, clientId } ) { | |
| // Get the stored attribute field ID. |
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
| // https://make.wordpress.org/core/2020/03/02/general-block-editor-api-updates/ | |
| // https://github.com/WordPress/gutenberg/tree/trunk/packages/core-data | |
| import { | |
| PanelRow, TextControl, | |
| } from '@wordpress/components'; | |
| import { useSelect } from '@wordpress/data'; | |
| import { useEntityProp } from '@wordpress/core-data'; | |
| import { PluginDocumentSettingPanel } from '@wordpress/edit-post'; | |
| import { registerPlugin } from '@wordpress/plugins'; |
Authentication means determining who a particular user is. Authorization means applying rules about what they can do. Blazor contains features for handling both aspects of this.
It worth remembering how the overall goals differ between server-side Blazor and client-side Blazor:
- Server-side Blazor applications run on the server. As such, correctly-implemented authorization checks are both how you determine which UI options to show (e.g., which menu entries are available to a certain user) and where you actually enforce access rules.
- Client-side Blazor applications run on the client. As such, authorization is only used as a way of determining what UI options to show (e.g., which menu entries). The actual enforcement of authorization rules must be implemented on whatever backend server your application operates on, since any client-side checks can be modified or bypassed.
Often see library code similar to this:
// NOTE: Do not use this or similar code
(function(global) {
'use strict';
global.$ = {};
})(window);
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
| /* | |
| In this code sample, you can learn how to apply custom | |
| validations on any fields you want. | |
| This can be done using these steps: | |
| 1. Edit the field in backend (field modal) | |
| 2. Where it asks for field validation choose "Custom" | |
| 3. Enter a unique validation action name e.g. my_8numbers |
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
| /* add new tab called "mytab" */ | |
| add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 ); | |
| function my_custom_tab_in_um( $tabs ) { | |
| $tabs[800]['mytab']['icon'] = 'um-faicon-pencil'; | |
| $tabs[800]['mytab']['title'] = 'My Custom Tab'; | |
| $tabs[800]['mytab']['custom'] = true; | |
| return $tabs; | |
| } | |
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
| add_filter( 'mime_types', 'aco_extend_mime_types' ); | |
| function aco_extend_mime_types( $existing_mimes ) { | |
| // Add webm, mp4 and OGG to the list of mime types | |
| $existing_mimes['webm'] = 'video/webm'; | |
| $existing_mimes['mp4'] = 'video/mp4'; | |
| $existing_mimes['ogg'] = 'video/ogg'; | |
| // Return an array now including our added mime types |