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
import json | |
from .models import MyModel | |
def get_json(request): | |
# Return JSON for filtered MyModel objects | |
records = MyModel.objects.filter(myproperty=myvalue) |
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 to check whether to remember the sorting order or not | |
* | |
* @param array $analyzed_sql_results the analyzed query and other variables set | |
* after analyzing the query | |
* | |
* @return boolean | |
*/ | |
function PMA_isRememberSortingOrder($analyzed_sql_results) | |
{ |
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
// following function will be use when you apply this shortcode: [render-posts type="post"] | |
function post_template($id){ | |
$c_id = $id; | |
$post_img_url = get_the_post_thumbnail_url($c_id, 'large'); | |
$title = esc_html(get_the_title($c_id)); | |
$html = ''; | |
$html .= '<a href="'.get_permalink($c_id).'" class="default-post-template">'; | |
if($post_img_url): | |
$html .= '<img src="'.$post_img_url.'" alt="'.$title.'">'; | |
endif; |
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
/** | |
* This function will return array start and end index | |
* which can be use in array slice Method | |
* @param {int} pageNumber | |
* @param {int} posts_per_page | |
* Logic Behind it | |
* 5 | |
0 0 5 | |
1 5 10 | |
2 10 15 |
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 | |
// require 'auth.php'; | |
$username = 'username'; | |
$password = 'password'; | |
$url = 'https://us19.api.mailchimp.com'; | |
// $postvars = "[email protected]&status=subscribed"; | |
$postvars = [ | |
"email_address"=> "[email protected]", | |
"status"=> "subscribed", | |
"merge_fields" => [ |
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(console){ | |
console.save = function(data, filename){ | |
if(!data) { | |
console.error('Console.save: No data') | |
return; | |
} | |
if(!filename) filename = 'console.json' |
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 | |
use Carbon_Fields\Container; | |
use Carbon_Fields\Field; | |
use Carbon_Fields\Block; | |
add_action( 'carbon_fields_register_fields', 'dd' ); | |
function dd(){ | |
// var_dump( WP_Block_Type_Registry::get_instance()->get_all_registered() ); | |
Block::make( __( 'My Shiny Gutenberg Block' ) ) |
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
HTML, PHP | |
{ | |
"php tag": { | |
"prefix": "php", | |
"body": ["<?php $1 ?>"], | |
"description": "php" | |
}, | |
"coder618_print": { | |
"prefix": "coder618_print_markup", | |
"body": ["<?php coder618_print_markup($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
function returnIndex() { | |
var postsPerPage = 12; | |
console.log('return start endindex ', page, postsPerPage); | |
let startIndex = postsPerPage * page; | |
let endIndex = startIndex + postsPerPage; | |
return [ startIndex, endIndex ]; | |
} |