Kako pouzdano iz PHP-a setapirati JS date
$tz = new DateTimeZone($this_city_tz);
$date = new DateTime();
$date->setTimeZone($tz);
$date_time = $date->format('Y-m-d H:i:s');
$date_time_js = $date->format('Y/m/d H:i:s');
var currentDate = new Date('<?php echo gmdate("r", strtotime($date_time_js)); ?>');
console.log(currentDate);
global $wpdb, $wp_actions;
$wpdb->queries = array();
$wp_actions = array();
wp_cache_flush();
$my_string = filter_input(INPUT_GET, ‘my_string’, FILTER_SANITIZE_STRING);
Manual
ob_start();
var_dump($param);
$param_vd = ob_get_clean();
function am2_tv_show_usermeta_fields($user) {
?>
<h3>Promotor information</h3>
<table class="form-table">
<tr>
<th><label for="am2_promotor_type">Type</label></th>
<td>
<?php
$selected_option = get_the_author_meta( 'am2_promotor_type', $user->ID );
?>
<select name="am2_promotor_type" id="am2_promotor_type">
<option selected value="">Please select something...</option>
<option value="basic" <?php if($selected_option == 'basic'){ echo 'selected'; } ?> >Basic</option>
<option value="featured" <?php if($selected_option == 'featured'){ echo 'selected'; } ?> >Featured</option>
<option value="premium" <?php if($selected_option == 'premium'){ echo 'selected'; } ?> >Premium</option>
</select>
<span class="description">Please select promotor type.</span>
</td>
</tr>
</table>
<?php
}
function am2_tv_update_usermeta_fields( $user_id ) {
if ( !current_user_can( 'administrator', $user_id ) ){
return false;
}
update_usermeta( $user_id, 'am2_promotor_type', $_POST['am2_promotor_type'] );
}
add_action( 'show_user_profile', 'am2_tv_show_usermeta_fields', 10, 2 );
add_action( 'personal_options_update', 'am2_tv_update_usermeta_fields', 10, 2 );
add_action( 'edit_user_profile_update', 'am2_tv_update_usermeta_fields', 10, 2 );
add_action( 'edit_user_profile', 'am2_tv_show_usermeta_fields', 10, 2 );
Source
$customPosts = new WP_Query($yourArgs);
echo "Last SQL-Query: {$customPosts->request}";
OR
First, put this in wp-config.php:
define( 'SAVEQUERIES', true );
Then in the footer of your theme put this:
<?php
if ( current_user_can( 'administrator' ) ) {
global $wpdb;
echo "<pre>";
print_r( $wpdb->queries );
echo "</pre>";
}
?>
Source
function am2_cities_tax_create() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[time_zone]">Time Zone</label>
<input type="text" name="term_meta[time_zone]" id="term_meta[time_zone]" value="">
<p class="description">If unusure, please check <a href="http://www.timeanddate.com/worldclock/">here.</a></p>
</div>
<?php
}
add_action( 'cities_add_form_fields', 'am2_cities_tax_create', 10, 2 );
function am2_cities_tax_update($term) {
// this will add the custom meta field to the update term page
// put the term ID into a variable
$t_id = $term->term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option( "taxonomy_$t_id" );
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="term_meta[time_zone]">Time Zone</label></th>
<td>
<input type="text" name="term_meta[time_zone]" id="term_meta[time_zone]" value="<?php echo esc_attr( $term_meta['time_zone'] ) ? esc_attr( $term_meta['time_zone'] ) : ''; ?>">
<p class="description">If unusure, please check <a href="http://www.timeanddate.com/worldclock/">here.</a></p>
</td>
</tr>
<?php
}
add_action( 'cities_edit_form_fields', 'am2_cities_tax_update', 10, 2 );
function am2_cities_tax_custom_meta_save( $term_id ) {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$cat_keys = array_keys( $_POST['term_meta'] );
foreach ( $cat_keys as $key ) {
if ( isset ( $_POST['term_meta'][$key] ) ) {
$term_meta[$key] = $_POST['term_meta'][$key];
}
}
// Save the option array.
update_option( "taxonomy_$t_id", $term_meta );
}
}
add_action( 'edited_cities', 'am2_cities_tax_custom_meta_save', 10, 2 );
add_action( 'create_cities', 'am2_cities_tax_custom_meta_save', 10, 2 );
Treba korigirati wp-config.php
define('WP_POST_REVISIONS', false ); // disable post revisions
define('WP_POST_REVISIONS', 3); // alter number of post revisions kept.
Documentation
function is(type, obj) {
var clas = Object.prototype.toString.call(obj).slice(8, -1);
return obj !== undefined && obj !== null && clas === type;
}
is('String', 'test'); // true
is('String', new String('test')); // true
is('Date', new Date()); // true
Source
$from_email = 'mailer@server.com';
$to_email = $seller->user_email;
$headers = "From: FROM NAME <$from_email>" . "\r\n";
$msg = "Ovo je poruka sa WP servera";
$subject = "WP mail subject";
$attachments = 'neki_file';
wp_mail($to_email, $subject, $msg, $headers, $attachments);
dz42 Wiki & Knowledge Base