Skip to content

Instantly share code, notes, and snippets.

View aslamatwebdevstudios's full-sized avatar

Aslam Doctor aslamatwebdevstudios

View GitHub Profile
@aslamatwebdevstudios
aslamatwebdevstudios / gist:22f57900c964adba054f4d33a3c81cc0
Created September 26, 2023 17:18
Allow specific tags to be added in the Wordpress content editor
function mysite_allow_form_tags( $tags, $context) {
$tags['form'] = array(
'action' => true,
'method' => true,
'enctype' => true,
'name' => true,
'id' => true,
'class' => true,
'target' => true
@aslamatwebdevstudios
aslamatwebdevstudios / wds_get_acf_link_html.php
Created May 15, 2023 19:34
Get link html generated using acf link field
@aslamatwebdevstudios
aslamatwebdevstudios / current-page-url.php
Created May 9, 2023 18:40
Get current page URL without query strings
<?php
/**
* Get current page URL without query strings
*/
function mytheme_get_current_url() {
if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$host = $_SERVER['HTTP_X_FORWARDED_HOST'];
} else {
$host = $_SERVER['HTTP_HOST'];
@aslamatwebdevstudios
aslamatwebdevstudios / theme.json
Created April 28, 2023 14:55
Example theme.json file
{
"version": 1,
"settings": {
"color": {
"primary": "#0073aa",
"secondary": "#005b8e",
"text": "#333",
"background": "#f5f5f5"
},
"typography": {
<?php
function my_plugin_enqueue($hook) {
if ( 'edit.php' === $hook ) {
$file_path = plugin_dir_path( __FILE__ ) . 'css/edit_page_styles.css';
$version = filemtime( $file_path );
wp_register_style(
'my_plugin_main_css',
plugins_url( '/css/edit_page_styles.css', __FILE__ ),
array(),
$version
@aslamatwebdevstudios
aslamatwebdevstudios / wds_classic_editor_styles.php
Created April 28, 2023 14:51
WordPress Classic Editor Styles
<?php
function my_plugin_add_editor_style() {
$editor_style_url = plugins_url( 'css/editor-style.css', __FILE__ );
$editor_style_path = plugin_dir_path( __FILE__ ) . 'css/editor-style.css';
$editor_style_version = filemtime( $editor_style_path );
add_editor_style( $editor_style_url . '?ver=' . $editor_style_version );
}
add_action( 'admin_init', 'my_plugin_add_editor_style' );
<?php
function my_theme_register_button_styles() {
wp_register_style(
'my-theme-button-styles',
get_stylesheet_directory_uri() . '/button-styles.css',
array(),
filemtime( get_stylesheet_directory() . '/button-styles.css' )
);
register_block_style(
@aslamatwebdevstudios
aslamatwebdevstudios / wds_enqueue_block_editor_styles_inc_frontend.php
Created April 28, 2023 14:45
Enqueue block editor styles including Front end
<?php
function my_enqueue_block_assets() {
wp_enqueue_style(
'my-block-editor-styles',
get_template_directory_uri() . '/css/my-block-styles.css',
array(),
filemtime( get_template_directory() . '/css/my-block-styles.css' ),
'all'
);
}
<?php
function my_enqueue_block_editor_assets() {
wp_enqueue_style(
'my-block-editor-styles',
get_theme_file_uri( 'block-editor-style.css' ),
array(),
filemtime( get_theme_file_path( 'block-editor-style.css' ) ),
'all'
);
}
<?php
function my_plugin_enqueue() {
$file_path = plugin_dir_path( __FILE__ ) . 'css/styles.css';
$version = filemtime( $file_path );
wp_register_style(
'my_plugin_main_css',
plugins_url( '/css/styles.css', __FILE__ ),
array(),
$version
);