View search-query.sql
SELECT rezultat, ord
FROM (
SELECT wp_posts.post_title rezultat, 1 ord, wp_posts.ID ID, wp_posts.post_type type, wp_posts.post_status status FROM wp_posts WHERE wp_posts.post_title LIKE '%search query%'
UNION
SELECT wp_posts.post_content rezultat, 2 ord, wp_posts.ID ID, wp_posts.post_type type, wp_posts.post_status status FROM wp_posts WHERE wp_posts.post_content LIKE '%search query%'
UNION
SELECT wp_postmeta.meta_value rezultat, 3 ord, wp_postmeta.post_id ID, 1 type, 1 status FROM wp_postmeta WHERE wp_postmeta.meta_value LIKE '%search query%'
) rez
WHERE 1=1
AND (rez.type = 'post' OR rez.type = 'page' OR rez.type = 'faq-type')
View advent-day4.php
<?php
$file = file_get_contents( 'input4.txt' );
// Create array by splitting the input by newline
$arr = array_filter( preg_split( '/\\r\\n|\\r|\\n/', $file ) );
$unique = 0;
foreach ( $arr as $arr_key => $arr_value ) {
$arr_sing = array_filter( preg_split( '/\\s/', $arr_value ) );
View advent-day2-2.php
<?php
$file = nl2br( file_get_contents( 'input.txt' ) );
$arr = array_filter( preg_split( '/\\r\\n|\\r|\\n/', $file ) );
$res = [];
function divison_check( $arr ) {
$cur_num;
$arr_len = count( $arr );
View advent-day2-1.php
<?php
$file = nl2br( file_get_contents( 'input.txt' ) );
// Create array by splitting the input by newline
$arr = array_filter( preg_split( '/\\r\\n|\\r|\\n/', $file ) );
$res = [];
foreach ( $arr as $a_key => $a_value ) {
// Create a new array by splitting the string by tabs
$single_arr = preg_split( '/\t/', $a_value );
View advent-day1-1.php
<?php
$re = '/(\d{1})(?=\1)/';
$str = '878938232157342756754254716586 97512539486529734932123658657466299442989425982853684278119925216918274344943523119443636821859946339154446174547292291656241485427544998344282834446389361828242524264332282291685793524214163618785991962688579157226827244271198836776286574134146727471814925517368683926587418417698556199645425316578419292945367832693772857178121215534659243287424474181616632869395852993836757566966322833556643527348433145288317598195567933532723199545223111893639319258333822259598252283346853326222487463744962464431841874861794941793922898829339194145772264193641745624389418266819717425578644599456747758271569233624924325471165352987133612982573524966742523857395233992294821421887241785852519964219458844854356547484727298423263746666469521717635828378878184317163684121567585177898461937757569644736684485428953421528695972768841973197663132383389224743814982997585616175512285764373194591333555628881711299391169497266765691423899929183199716341254897764949122
View advent-day1.php
<?php
$re = '/(\d{1})(?=\1)/';
$str = '878938232157342756754254716586 97512539486529734932123658657466299442989425982853684278119925216918274344943523119443636821859946339154446174547292291656241485427544998344282834446389361828242524264332282291685793524214163618785991962688579157226827244271198836776286574134146727471814925517368683926587418417698556199645425316578419292945367832693772857178121215534659243287424474181616632869395852993836757566966322833556643527348433145288317598195567933532723199545223111893639319258333822259598252283346853326222487463744962464431841874861794941793922898829339194145772264193641745624389418266819717425578644599456747758271569233624924325471165352987133612982573524966742523857395233992294821421887241785852519964219458844854356547484727298423263746666469521717635828378878184317163684121567585177898461937757569644736684485428953421528695972768841973197663132383389224743814982997585616175512285764373194591333555628881711299391169497266765691423899929183199716341254897764949122
View search-modification.php
<?php
/**
* Modification of the default WordPress search
*
* By default, the WordPress search is very rigid. It checks the post table's
* title, content and excerpt with a '%LIKE%' keyword. So the search is very
* limited.
* This will modify the search clause and do a fulltext search. For more information
* about fulltext you can read about it here: https://www.digitalocean.com/community/tutorials/how-to-improve-database-searches-with-full-text-search-in-mysql-5-6-on-ubuntu-16-04
*
View fulltext-check.sql
SELECT TABLE_SCHEMA, TABLE_NAME
FROM statistics
WHERE index_type LIKE 'FULLTEXT%'
View gist:db8ee2cc028ca2ad916de414ecd468b3
SELECT TABLE_SCHEMA, TABLE_NAME
FROM statistics
WHERE index_type LIKE 'FULLTEXT%'
View acf-repeater-query.php
<?php
// Assuming we have ACF.
$rows = get_field('images');
// Regular ACF query with 10 images in repeater yeilds 34 queries
foreach ($rows as $row) :
$image_id = $row['image'];
$image = wp_get_attachment_image_src($image_id, 'your-custom-image-size');
echo '<img src="'. $image[0] . '" width="'. $image[1] . '" height="'. $image[2] . '" />';
endforeach;