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 | |
$categories = get_the_category(); | |
// Assemble a tree of category relationships | |
// Also re-key the category array for easier | |
// reference | |
$category_tree = array(); | |
$keyed_categories = array(); |
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 | |
//relation for deletting in migration | |
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); | |
//if exist | |
Notification::where('tel', '=', $tel)->where('read', '=', '1')->exists(); | |
//create | |
irantime(); |
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 array_insert( $array, $index, $insert ) { | |
return array_slice( $array, 0, $index, true ) + $insert + | |
array_slice( $array, $index, count( $array ) - $index, true); | |
} | |
add_filter( 'manage_resource_posts_columns' , function ( $columns ) { | |
return array_insert( $columns, 2, [ | |
'image' => 'Featured Image' | |
] ); | |
}); |
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
/** | |
* A widget that does amazing things! | |
*/ | |
class Amazing_Widget extends WP_Widget { | |
/** | |
* Registers the widget with the WordPress Widget API. | |
* | |
* @return void. | |
*/ | |
public static function register() { |
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
$args = array( | |
'posts_per_page' => -1, | |
'product_cat' => $cat, | |
'post_type' => 'product', | |
'orderby' => 'meta_value_num', | |
'meta_key' => '_price', | |
'order' => 'asc' | |
); |
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
<!DOCTYPE html> | |
<html> | |
<body> | |
<style> | |
#holder.hover { border: 10px dashed #0c0 !important; } | |
</style> | |
<form method="post" action="http://httpbin.org/post" enctype="multipart/form-data"> | |
<input id="name"><br/> | |
<input id="type"><br/> | |
<input id="size"><br/> |
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
console.log(jqXHR.status); //https://developer.mozilla.org/en-US/docs/Web/HTTP/Status | |
console.log(jqXHR.readyState); //https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState | |
console.log(jqXHR.responseJSON); | |
console.log(jqXHR.responseText); | |
$.ajax({ | |
url: wp_extensions_js_var.wp_rest_url + '/' + token + '/v1/test-connection?domain=' + domain, | |
type: 'get', | |
dataType: "json", | |
cache: false, |
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
require_once str_replace("\\","/",get_template_directory()) . '/includes/phpexcel/PHPExcel.php'; | |
// Create new PHPExcel object | |
//$objPHPExcel = new PHPExcel(); | |
// Create new PHPExcel object | |
$upload_dir = str_replace("\\","/",wp_upload_dir()['basedir']); | |
try { |
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
add_filter( | |
'user_row_actions', | |
function($actions, $user_object) { | |
$result = new WP_Query( | |
array( | |
'author'=> $user_object->ID, | |
'post_type'=>'portfolio', | |
'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
// https://www.kevinleary.net/wordpress-pagination-paginate_links/ | |
/* | |
* custom pagination with bootstrap .pagination class | |
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/ | |
*/ | |
function bootstrap_pagination( $echo = true ) { | |
global $wp_query; |