First, Lets find out what version of PHP we're running (To find out if it's the default version).
To do that, Within the terminal, Fire this command:
which php
function enableCommentByCat() { | |
global $wpdb; | |
$getPosts = new WP_Query( array( 'category_name' => 'ten_category') ); | |
if ( $getPosts->have_posts() ) { | |
while ( $getPosts->have_posts() ) { | |
$getPosts->the_post(); | |
$postId = get_the_ID(); | |
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open' WHERE ID=$postId")); | |
} | |
} else { |
<? | |
/** | |
* @param String $str The input string | |
* @return String The string without accents | |
*/ | |
function removeAccents( $str ) | |
{ | |
$a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', | |
'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', | |
'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', |
<?php | |
// ======= PATHINFO ====== // | |
$x = pathinfo($url); | |
$x['dirname'] 🡺 https://example.com/subFolder | |
$x['basename'] 🡺 myfile.php?var=blabla#555 // Unsecure! | |
$x['extension'] 🡺 php?var=blabla#555 // Unsecure! | |
$x['filename'] 🡺 myfile | |
// ======= PARSE_URL ====== // | |
$x = parse_url($url); |
[ | |
{ | |
"name": "(UTC -11:00) Pacific/Midway", | |
"code": "Pacific/Midway" | |
}, | |
{ | |
"name": "(UTC -11:00) Pacific/Niue", | |
"code": "Pacific/Niue" | |
}, | |
{ |
<?php | |
function install_next_post_sc(){ | |
$class = 'next_post_'; | |
global $post; | |
$categories = get_the_category($post->ID); | |
if(!empty($categories)){ | |
$category = $categories[0]->term_id; | |
} else { | |
$category = ''; | |
} |
<?php | |
/** | |
* Infinite next and previous post looping in WordPress | |
*/ | |
if( get_adjacent_post(false, '', true) ) { | |
previous_post_link('%link', '← Previous Post'); | |
} else { | |
$first = new WP_Query('posts_per_page=1&order=DESC'); $first->the_post(); | |
echo '<a href="' . get_permalink() . '">← Previous Post</a>'; | |
wp_reset_query(); |
<?php | |
add_filter('the_content', function ($content) { | |
$toc_output = ''; | |
$matches = null; | |
$smatches = null; | |
$had_headers = array(); | |
preg_match_all('/<h[2-3].*?>.*?<\/h[2-3]>/i', $content, $matches); | |
if (!empty($matches[0]) && count($matches[0]) > 0) | |
foreach ($matches[0] as $headertag) { | |
preg_match('/>(.*?)<\/(h[2-3])>/i', $headertag, $smatches); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
const warningTitleCSS = 'color:red; font-size:60px; font-weight: bold; -webkit-text-stroke: 1px black;'; | |
const warningDescCSS = 'font-size: 18px;'; |