This file contains 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 | |
if ( wp_is_block_theme() && is_front_page() ) { | |
$block_template = get_block_templates( [ 'slug__in' => [ 'home' ] ] ); | |
$block_content = isset( $block_template[0] ) ? $block_template[0]->content : ''; | |
$home_has_block = has_block( 'my/block', $block_content ); | |
} |
This file contains 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
const rootPath = 'your-project/root-path'; | |
export default defineConfig() => { | |
build: { | |
rollupOptions: { | |
output: { | |
entryFileNames: (assetInfo) => assetInfo.facadeModuleId.replace( path.resolve( __dirname, rootPath ) + '/', '' ), | |
} | |
} | |
} |
This file contains 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
import path from 'path' | |
export default (cssBundleNameIndex = []) => ({ | |
/** | |
* @see https://rollupjs.org/guide/en/#renderchunk | |
*/ | |
renderChunk(code, chunkInfo) { | |
const { | |
fileName: jsFileName, |
This file contains 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 | |
if ( !class_exists( '\Yoast\WP\Lib\Model' ) || !class_exists( '\Yoast\WP\SEO\Models\Indexable' ) ) { | |
return; | |
} | |
// The post ID | |
$object_id = 123; | |
// The post object type (post type) |
This file contains 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 | |
preg_match_all( '@<iframe[^>]+?src="((?:https?:)?//(?:docs\.)?google\.com/([^"\'/]++)[^"\']*?)"[^>]*+>.*</iframe>@iUs', $content, $matches ); | |
if ( isset( $matches[0] ) && isset( $matches[0][0] ) ) { | |
foreach ( $matches[0] as $googleDocIframe ) { | |
$content = str_replace( $googleDocIframe, '<div class="google-doc-iframe">' . $googleDocIframe . '</div>', $content ); | |
} | |
} |
This file contains 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
// Get all the elements | |
document.querySelectorAll( '.my-element' ).forEach( (el) => { | |
var prevEl = el.previousElementSibling, nextEl = el.nextElementSibling, elArr = [], html = ''; | |
if ( prevEl === null || nextEl === null ) return; | |
// In case you want to include the two elements before the previous sibling | |
[prevEl.previousElementSibling, prevEl.previousElementSibling.previousElementSibling].forEach((topEl) => { | |
if ( topEl !== null ) elArr.push(topEl); | |
}) |
This file contains 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 | |
$attachment_id = $your_way_of_getting_the_id; | |
$file_path = '2022/02/my-image.jpg'; | |
// Update the path inside the post meta | |
update_post_meta( $attachment_id, '_wp_attached_file', $attachment_id ); | |
$old_metadata = wp_get_attachment_metadata( $attachment_id ); | |
$old_metadata['file'] = $attachment_id; |
This file contains 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 | |
add_filter( 'wpseo_sitemap_exclude_post_type', 'your_prefix_exclude_cpt_from_sitemap', 10, 2 ); | |
function your_prefix_exclude_cpt_from_sitemap( $value, $post_type ) { | |
$post_types_to_exclude = [ | |
'post_type_one', | |
'post_type_two' | |
]; | |
if ( in_array($post_type, $post_types_to_exclude) ) { |
This file contains 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 | |
// Options | |
$secret_token = 'YOUR_SECRET_TOKEN'; | |
$database_id = 'YOUR_DATABASE_ID'; | |
$notion_version = '2021-08-16'; | |
// Post url | |
$post_url = 'https://api.notion.com/v1/pages'; |
This file contains 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 | |
// Access token with App Id | |
$appId = ""; | |
$accessToken = ""; | |
function fetchData( $url ) { | |
$ch = curl_init(); | |
curl_setopt( $ch, CURLOPT_URL, $url ); | |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); | |
curl_setopt( $ch, CURLOPT_TIMEOUT, 20 ); |
NewerOlder