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 | |
/** | |
* Get terms with the same slug in two different taxonomies. | |
* | |
* @param string $taxonomy_1 The first taxonomy. | |
* @param string $taxonomy_2 The second taxonomy. | |
* @return array An associative array where the key is the term ID of taxonomy_1 and the value is the term ID of taxonomy_2. | |
*/ | |
function get_terms_with_same_slug($taxonomy_1, $taxonomy_2) { | |
$terms_taxonomy_1 = get_terms([ |
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 | |
function login_case_sensitive( $user, $username, $password ) { | |
$user_id = username_exists($username); | |
if( !$user_id ) { | |
return $user; | |
} | |
$user_obj = get_user_by('id', $user_id); | |
if( $username !== $user_obj->user_login ) { | |
return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: Invalid username or password.' ) ); |
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 | |
//add the hook in page.php after entry-content | |
/* <?php do_action('si_after_entry_content_action'); ?>*/ | |
// Back to Top | |
add_action( 'si_after_entry_content_action', function () { if ( !is_admin() ) { | |
?> | |
<div id="back-to-top" class="back-to-top" > | |
<!--add image here--> |
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
function si_announce_functions() { | |
if (!isset($_COOKIE['announcement_closed']) && !is_user_logged_in()) { | |
?> | |
<div id="si-ann-main-" class="si-announce-main-div"> | |
<div class="si-announce-main si-container"> | |
<p class="cookie-announce-para"> | |
Become a local news contributor! <a class="si-announcement-link" href="/login/" target="_blank">Sign up for free</a> and start posting your events and news today. | |
</p> | |
<span class="close-btn-announce" onclick="hideAnnouncement()"> |
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
document.addEventListener("DOMContentLoaded", function() { | |
/* animate counter | |
* <span class="animate-count">1000</span> | |
*/ | |
function isElementInViewport(el) { | |
var rect = el.getBoundingClientRect(); |
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
var ua = window.navigator.userAgent; | |
var iOS = ua.match(/iPad/i) || ua.match(/iPhone/i); | |
var webkit = ua.match(/WebKit/i); | |
var iOSSafari = iOS && webkit && !ua.match(/CriOS/i); | |
console.log("ios: "+ iOS + " | webkit: "+ webkit +" | ios safari: "+ iOSSafari); |
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 | |
$query_cpt = new WP_Query($args); | |
$posts_per_page = $query_cpt->query_vars['posts_per_page']; | |
$posts_found = $query_cpt->found_posts; | |
$paged = $query_cpt->query_vars['paged']; | |
if ( $posts_found ) { | |
$start_result = ( $paged - 1 ) * $posts_per_page + 1; |
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 | |
add_filter( 'wp_all_import_single_image_uploads_dir', 'wpai_wp_all_import_single_image_uploads_dir', 10, 6 ); | |
function wpai_wp_all_import_single_image_uploads_dir( $uploads, $image_url, $articleData, $current_xml_node, $import_id, $post_id ) { | |
$position = strpos($image_url, 'uploads'); | |
$result = substr($image_url, $position + 7,8); //eg: `/2021/05` | |
$uploads['path'] = $uploads['basedir'].$result; | |
$uploads['url'] = $uploads['baseurl'].$result; | |
$uploads['subdir']=$result; |
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 | |
// Add a filter to modify the HTTP headers | |
function add_csp_header() { | |
header("Content-Security-Policy: default-src 'self'; script-src 'self' https://example.com; style-src 'self' https://example.com;"); | |
// Add more directives as needed based on your specific requirements | |
} | |
// Hook the function to the 'send_headers' action | |
add_action('send_headers', 'add_csp_header'); |
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 | |
// Synchronize terms between the two taxonomies | |
function synchronize_taxonomies( $term_id, $tt_id, $taxonomy ) { | |
if (in_array($taxonomy, array('first_taxonomy', 'second_taxonomy'))) { | |
$term = get_term($term_id, $taxonomy); | |
$other_taxonomy = ($taxonomy === 'first_taxonomy') ? 'second_taxonomy' : 'first_taxonomy'; | |
// Check if the term exists in the other taxonomy | |
$term_exists = term_exists($term->name, $other_taxonomy); |
NewerOlder