new post wp_insert_post()
php
wp
$my_post = array( ‘post_title’ => wp_strip_all_tags( $_POST[‘post_title’] ), ‘post_content’ => $_POST[‘post_content’], ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array( 8,39 ) ); // Insert the post into the database wp_insert_post( $my[...]
$my_post = array( ‘post_title’ => wp_strip_all_tags( $_POST[‘post_title’] ), ‘post_content’ => $_POST[‘post_content’], ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array( 8,39 ) ); // Insert the post into the database wp_insert_post( $my_post );
1
set timeout function
js
setTimeout(function(){ console.log("Hello World"); }, 2000);
setTimeout(function(){ console.log("Hello World"); }, 2000);
2
document ready function
jquery
js
$( document ).ready(function() { console.log( "ready!" ); });
$( document ).ready(function() { console.log( "ready!" ); });
4
list all categories get_categories()
php
wp
$categories = get_categories( array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘exclude’ => ‘1’, ‘hide_empty’ => 0,) );
$categories = get_categories( array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘exclude’ => ‘1’, ‘hide_empty’ => 0,) );
12
ajax GET single pages s
jquery
js
$.ajax({ url:"https://url.here.com", method:"GET", data:{id:id}, success:function(data){ $('#r'+id).html(data); } [...]
$.ajax({ url:"https://url.here.com", method:"GET", data:{id:id}, success:function(data){ $('#r'+id).html(data); } });
6
php show errors
php
ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL);
ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL);
2
rainbow css animation background-color @keyframes
css
@keyframes rainbow { 0% { background: rgb(243, 162, 162, 0.5); } /* Adding a step in the middle */ 10% { background: rgb(229, 202, 150, 0.5); } 20% { background: rgb(236, 211, 98, 0.5); } 30% { background: rgb(120, 241, 151, 0.5);[...]
@keyframes rainbow { 0% { background: rgb(243, 162, 162, 0.5); } /* Adding a step in the middle */ 10% { background: rgb(229, 202, 150, 0.5); } 20% { background: rgb(236, 211, 98, 0.5); } 30% { background: rgb(120, 241, 151, 0.5); } 40% { background: rgb(31, 218, 115, 0.5); } 50% { background: rgb(133, 240, 225, 0.5); } 60% { background: rgb(98, 181, 236, 0.5); } 70% { background: rgb(165, 134, 238, 0.5); } 80% { background: rgb(238, 134, 238, 0.5); } 90% { background: rgb(230, 109, 193, 0.5); } 100% { background: rgb(238, 134, 151, 0.5); } }
4
jquery on click event
jquery
js
.click( function(){});
.click( function(){});
3
css animation referencing
css
animation: pulse 1s infinite
animation: pulse 1s infinite
5
ajax POST full form
jquery
js
event.preventDefault(); // stop default form action $.ajax({ url:"inc.php", method:"POST", data:$('#insert_form').serialize(), beforeSend:function(){ $('#insert').val("Inserting"); }, success:function(data){ $('#ins[...]
event.preventDefault(); // stop default form action $.ajax({ url:"inc.php", method:"POST", data:$('#insert_form').serialize(), beforeSend:function(){ $('#insert').val("Inserting"); }, success:function(data){ $('#insert_form')[0].reset(); $('#plant_list_html').html(data); } });
5
replace line break with comma tool
html
https://convert.town/replace-new-lines-with-commas
https://convert.town/replace-new-lines-with-commas
5
show loadtime for wordpress
php
wp
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
php measure pageload time
php
$time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; /////// $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo 'Page generat[...]
$time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; /////// $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo 'Page generated in '.$total_time.' seconds.';
center x center y flex child
css
display: flex; align-items: center; /* t-b */ justify-content: center; /* l-r */
display: flex; align-items: center; /* t-b */ justify-content: center; /* l-r */
23
DataTables Intit function()
jquery
$('#sale_table').DataTable({ "order": [[ 0, 'desc' ]], "pageLength": 20} );
$('#sale_table').DataTable({ "order": [[ 0, 'desc' ]], "pageLength": 20} );
gsheets code
js
function onOpen() { SpreadsheetApp.getUi() .createMenu('Meilleur Avant') .addItem('Etat Végétal', 'showEtatVegetal') .addItem('Tartinade Cajou', 'showTartinadeCajou') .addToUi(); } function showEtatVegetal() { var today = new Date(); [...]
function onOpen() { SpreadsheetApp.getUi() .createMenu('Meilleur Avant') .addItem('Etat Végétal', 'showEtatVegetal') .addItem('Tartinade Cajou', 'showTartinadeCajou') .addToUi(); } function showEtatVegetal() { var today = new Date(); var dateInEightDays = new Date(today.getTime() + 8 * 24 * 60 * 60 * 1000); var formattedDate = Utilities.formatDate(dateInEightDays, Session.getScriptTimeZone(), 'dd/MM/yyyy'); var ui = SpreadsheetApp.getUi(); var htmlOutput = HtmlService.createHtmlOutput('<h1 style="color:#87c6b5; text-align: center; font-size: 68px; font-weight: bold;">' + formattedDate + '</h1>') .setWidth(500) .setHeight(200); ui.showModalDialog(htmlOutput, 'Etat Végétal (+ 7 jours demain)'); } function showTartinadeCajou() { var today = new Date(); var dateInFiftyDays = new Date(today.getTime() + 50 * 24 * 60 * 60 * 1000); var formattedDate = Utilities.formatDate(dateInFiftyDays, Session.getScriptTimeZone(), 'dd/MM/yyyy'); var ui = SpreadsheetApp.getUi(); var htmlOutput = HtmlService.createHtmlOutput('<h1 style="color:#87c6b5; text-align: center; font-size: 68px; font-weight: bold;">' + formattedDate + '</h1>') .setWidth(500) .setHeight(200); ui.showModalDialog(htmlOutput, 'Tartinade Cajou (+ 51 jours demain)'); }
device-scale meta tag
html
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
2
webhook api link home assistant
hassio
http://192.168.0.207:8123/api/webhook/
http://192.168.0.207:8123/api/webhook/
cna yo see me
Uncategorized
did iteo work
Uncategorized
1
WP Enqueue Script wp_enqueue_script()
php
wp
function add_theme_scripts() { wp_enqueue_script( 'main', get_template_directory_uri() . '/assets/js/main.js', array ( 'jquery' ), 1.1, true); $variables = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ); wp_localize_script('main', "jajax", $variabl[...]
function add_theme_scripts() { wp_enqueue_script( 'main', get_template_directory_uri() . '/assets/js/main.js', array ( 'jquery' ), 1.1, true); $variables = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ); wp_localize_script('main', "jajax", $variables); // add ajax variable to main.js wp_enqueue_style( 'style', get_stylesheet_uri() ); wp_enqueue_style( 'modal', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css', array(), '1.1', 'all'); wp_enqueue_script( 'fontawesome', 'https://kit.fontawesome.com/3267ecc051.js', array(), '1.1', false); wp_enqueue_script( 'modal', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js', array ( 'jquery' ), 1.1, true); } add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
AJAX Load Script in Functions.php
php
add_action("wp_ajax_action_name" , "action_name"); function action_name(){ // do things }
add_action("wp_ajax_action_name" , "action_name"); function action_name(){ // do things }
1
hjkhk
Uncategorized
jkhhk
jkhhk