// нахождение максимального значения
max = a > b ? a : b;
// нахождения первого валидного значения
result = x != null ? x : y != null ? y : null;
// возврат значения по условию
return exists ? a : b;
// тут не разложить в тернарный оператор
if (visible) {
a = displayObject.x; // установка переменной a
} else {
b = displayObject.y; // установка переменой b
}
не знаю насколько усложнит задачу делать его кроссплатформенным. Если не сильно, то тогда можно и напрячься.
за сколько дней и часов в эти дни примерно возможно сделать подобное приложение
// ....
PreparedStatement stat = c.prepareStatement("INSERT INTO snippets (snippetTitle, snippetCode, snippetDescr) VALUES (?,?,?)");
stat.setString(1,snippet.getSnippetTitle());
stat.setString(2,snippet.getSnippetCode());
stat.setString(3, snippet.getSnippetDescription());
stat.executeUpdate();
// ....
<?php
if (empty($wp)) {
require_once('wp-config.php');
}
global $wpdb;
$posts = $wpdb->get_results(
"SELECT
p.ID, p.post_name
FROM
wp_posts p
WHERE
p.post_type = 'post' AND p.post_status = 'publish'");
$double = array();
$rewrite = array();
foreach($posts as $post){
if (!array_key_exists($post->post_name,$double)){
$double[$post->post_name] = 0;
}else{
$double[$post->post_name] += 1;
$rewrite[$post->ID] = $post->post_name . "-" . $double[$post->post_name];
}
}
foreach($rewrite as $key => $value){
$wpdb->update( 'wp_posts',
array( 'post_name' => $value ),
array( 'ID' => $key )
);
}
function create_post_type() {
$labels = array(
'name' => 'Projects',
'singular_name' => 'Project',
'menu_name' => 'Projects',
'name_admin_bar' => 'Project',
'add_new' => 'Add New',
'add_new_item' => 'Add New Project',
'new_item' => 'New Project',
'edit_item' => 'Edit Project',
'view_item' => 'View Project',
'all_items' => 'All Projects',
'search_items' => 'Search Projects',
'parent_item_colon' => 'Parent Project',
'not_found' => 'No Projects Found',
'not_found_in_trash' => 'No Projects Found in Trash'
);
$args = array(
'labels' => $labels,
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-appearance',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
'rewrite' => array( 'slug' => 'projects' ),
'query_var' => true
);
register_post_type( 'sm_project', $args );
}
function create_taxonomies() {
// Add a taxonomy like categories
$labels = array(
'name' => 'Types',
'singular_name' => 'Type',
'search_items' => 'Search Types',
'all_items' => 'All Types',
'parent_item' => 'Parent Type',
'parent_item_colon' => 'Parent Type:',
'edit_item' => 'Edit Type',
'update_item' => 'Update Type',
'add_new_item' => 'Add New Type',
'new_item_name' => 'New Type Name',
'menu_name' => 'Types',
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'type' ),
);
register_taxonomy('sm_project_type',array('sm_project'),$args);
// Add a taxonomy like tags
$labels = array(
'name' => 'Attributes',
'singular_name' => 'Attribute',
'search_items' => 'Attributes',
'popular_items' => 'Popular Attributes',
'all_items' => 'All Attributes',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Attribute',
'update_item' => 'Update Attribute',
'add_new_item' => 'Add New Attribute',
'new_item_name' => 'New Attribute Name',
'separate_items_with_commas' => 'Separate Attributes with commas',
'add_or_remove_items' => 'Add or remove Attributes',
'choose_from_most_used' => 'Choose from most used Attributes',
'not_found' => 'No Attributes found',
'menu_name' => 'Attributes',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'attribute' ),
);
register_taxonomy('sm_project_attribute','sm_project',$args);
}