Uživatelské taxonomie, přidávání uživatelských polí k taxonomiím

„Custom user taxonomies »“:http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress

*

To add a custom field to your custom taxonomy, add the following code to your theme’s functions.php:
/—code php
// A callback function to add a custom field to our „presenters“ taxonomy
function presenters_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you’re editing
$t_id = $tag->term_id; // Get the ID of the term you’re editing
$term_meta = get_option( „taxonomy_term_$t_id“ ); // Do the check
?>

term_id“ );
// Return the value for the „presenter_id“ custom field
$presenter_data = get_userdata( $presenter_custom_fields[presenter_id] ); // Get their data
\—

To see what data is stored inside the custom fields you created, add the print_r function to your template, then preview it:
/—code php
‚; print_r( $presenter_custom_fields ); echo ‚

‚;
?>
\—

To keep it dynamic, we are passing in the „presenter_id“ field of our $presenter_custom_fields variable. Now, to see what data you have to work with, use print_r again:
/—code php
‚; print_r( $presenter_data ); echo ‚

‚;
?>
\—
„Zdroj: How To Add Custom Fields To Custom Taxonomies »“:http://sabramedia.com/blog/how-to-add-custom-fields-to-custom-taxonomies

***

To add a form field to the Edit Category screen we’ll use the edit_category_form_fields action hook available in WordPress:
/—code php
term_id, $cat_featured ) ) {
$featured_id = $cat_featured[$tag->term_id] ;
}
?>

The post ID that will be the featured post when viewing this category.


\—
The above code will add a single text field (Featured Post ID) to the Edit Category screen.

Now we need to save the input to our option array. To capture the ID when a category is updated we’ll use the edited_category action hook like so:

/—code php

\—
As you can see we are saving the Category ID and Featured Post ID as a single associative array option value in WordPress named category_featured. As you add Featured Post ID values to each of your categories they will be added to this array and saved in WordPress.

„Save Taxonomy Meta Data as an Options Array in WordPress »“:http://strangework.com/2010/07/01/how-to-save-taxonomy-meta-data-as-an-options-array-in-wordpress/

***

„How to Add Custom Meta Fields to Custom Taxonomies in WordPress »“:http://www.wpbeginner.com/wp-tutorials/how-to-add-additional-custom-meta-fields-to-custom-taxonomies/

„Adding Custom Meta Fields to Taxonomies »“:https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/

„How To Add Custom Fields To Custom Taxonomies»“:http://sabramedia.com/blog/how-to-add-custom-fields-to-custom-taxonomies

„WordPress: Adding custom fields to taxonomies »“:http://www.journal.deviantdev.com/wordpress-adding-custom-fields-to-taxonomies/

„WordPress Taxonomies Extra Fields the easy way »“:https://en.bainternet.info/wordpress-taxonomies-extra-fields-the-easy-way/

„Hooking WordPress Taxonomy Changes With The Plugins API »“:https://www.dougv.com/2014/06/hooking-wordpress-taxonomy-changes-with-the-plugins-api/

„Extending WordPress Taxonomies »“:http://www.sitepoint.com/extending-wordpress-taxonomies/

SEO pro WordPress

„The Beginner’s Guide to WordPress SEO by Yoast »“:http://code.tutsplus.com/tutorials/the-beginners-guide-to-wordpress-seo-by-yoast-configuration–wp-31022

„The Definitive Guide To Higher Rankings For WordPress Sites »“:https://yoast.com/articles/wordpress-seo/

„Guide to Advanced SEO »“:http://www.quicksprout.com/the-advanced-guide-to-seo-chapter-1/

„How To Stop Search Engines From Indexing Specific Posts And Pages In WordPress »“:http://www.elegantthemes.com/blog/tips-tricks/how-to-stop-search-engines-from-indexing-specific-posts-and-pages-in-wordpress

„Are You Setting Up WordPress For SEO Success? »“:http://moz.com/blog/setup-wordpress-for-seo-success

Vypnutí XML-RPC

XML-RPC is a Remote Procedure Call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism. XML-RPC is used to do something remotely to your blog such as posting, viewing comments, etc.
By default, WordPress enables XML-RPC automatically!

**Disable XML-RPC Pingback**
„https://wordpress.org/plugins/disable-xml-rpc-pingback/“:https://wordpress.org/plugins/disable-xml-rpc-pingback/

This is more friendly than disabling totally XML-RPC, that it’s needed by some plugins and apps (I.e. Mobile apps or some Jetpack’s modules).

Vypnutí pingbacků ve functions.php (totéž jako výše uvedený plugin)

/—code php
function remove_xmlrpc_pingback_ping( $methods ) {
unset( $methods[‚pingback.ping‘] );
return $methods;
}
add_filter( ‚xmlrpc_methods‘, ‚remove_xmlrpc_pingback_ping‘ );
\—

**How to disable XML-RPC manually:**

1) turn off XML-RPC in functions.php

/—code php
add_filter(‚xmlrpc_enabled‘, ‚__return_false‘);
\—

2) hide xmlrpc.php in HTTP response headers in functions.php

/—code php
function disable_x_pingback($headers)
{
unset( $headers[‚X-Pingback‘] );
return $headers;
}
add_filter(‚wp_headers‘, ‚disable_x_pingback‘);
\—

3) deny request to xmlrpc.php in .htaccess

/—code php

RedirectMatch 403 /xmlrpc.php

\—

or

/—code php

Order Deny,Allow
Deny from all

\—

„Zdroj »“:http://www.deluxeblogtips.com/2013/08/disable-xml-rpc-wordpress.html

Přidání nového příspěvku programátorsky

/—code php

/*
A function used to programmatically create a post in WordPress.
@returns -1 if the post was never created, -2 if a post with the same title exists, or the ID of the post if successful.
*/

function programmatically_create_post($user_id) {
// Initialize the page ID to -1. This indicates no action has been taken.
$post_id = -1;

// Setup the title of the post
$title = ‚My New Post‘

// If the page doesn’t already exist, then create it
if( null == get_page_by_title($title)) {
// Set the post ID so that we know the post was created successfully
$new_post = array(
‚post_title‘ => $title,
‚post_name‘ => my-new-post,
‚post_content‘ => ‚Lorem ipsum dolor sit amet…‘,
‚post_status‘ => ‚publish‘,
‚post_date‘ => date(‚j.n.Y H:i:s‘),
‚post_author‘ => $user_id,
‚post_type‘ => ‚post‘,
‚post_category‘ => array(0),
‚comment_status‘ => ‚closed‘,
‚ping_status‘ => ‚closed‘,
);
$post_id = wp_insert_post($new_post);
// Otherwise, we’ll stop
} else {
// Arbitrarily use -2 to indicate that the page with the title already exists
$post_id = -2;
} // end if
} // end programmatically_create_post
\—

„Programmatically Create a Post in WordPress »“:http://tommcfarlin.com/programmatically-create-a-post-in-wordpress/
„How to Create a Post in WordPress Programmatically »“:How to Create a Post in WordPress Programmatically

To lze využít např. pro automatické vytvoření příspěvku z uživatelského profilu při jeho ukládání přes „user_register hook“:http://codex.wordpress.org/Plugin_API/Action_Reference/user_register:

/—code php
add_action(‚user_register‘,’programmatically_create_post‘);
\—

Jak přidat tlačítko do HTML editoru

/—code php
// Add buttons to html editor
add_action(‚admin_print_footer_scripts‘,’eg_quicktags‘);
function eg_quicktags() {
?>

Manipulace s údaji v Contact Form 7 před a po odeslání

„WordPress Contact Form 7 Hook Unofficial Developer Documentation and Examples »“:http://xaviesteve.com/3298/wordpress-contact-form-7-hook-unofficial-developer-documentation-and-examples/

„Changing Form Data Before it is Saved »“:http://cfdbplugin.com/?page_id=747

„Contact Form 7 – form submit change field value »“:https://wordpress.org/support/topic/form-submit-change-field-value

„How to create a mail counter for Contact Form 7 »“:http://sevenspark.com/tutorials/how-to-create-a-counter-for-contact-form-7

„Extending the Contact Form 7 Plugin »“:http://kovshenin.com/2010/wordpress-extending-the-contact-form-7-plugin/

[private]

/—code php

### příklad použitý na http://u904.cz/mimoradna-nabidka-lifebook-a512/
### pocitadlo objednavek odeslanych z CF7

// Define the key to store in the database
define(‚CF7_COUNTER‘, ‚cf7-counter‘);
define(‚CF7_LASTORD‘, ‚cf7-lastord‘);
define(‚POCNAB‘, ‚200‘); // startovni pocet kusu

### Create the shortcode which will read the value from db option
function cf7db_reader(){
$val = get_option(CF7_COUNTER, POCNAB); // kdyz neexistuje option v db, vrati startovni pocet
return $val;
}
add_shortcode(‚CF7_show‘, ‚cf7db_reader‘);

### Action performed BEFORE the mail is sent by CF7
function wpcf7_change_mail($form) {
$formid = $form->id; // gets current form id
if ($formid == ‚384‘) {
$wpcf7 = WPCF7_ContactForm::get_current(); // get current FORM instance
$wpcf7data = WPCF7_Submission::get_instance(); // // get current SUBMISSION instance
if ($wpcf7data) {
$formData = $wpcf7data->get_posted_data();
}
// Reading a posted value in the form with PHP
$poc = $formData[‚pocet‘]; // nacte hodnotu z prave odeslaneho formulare
$val = get_option(CF7_COUNTER, POCNAB); // nacte aktualni hodnotu skladu, kdyz neexistuje option v db, vytvori a naplni ji startovnim poctem objednavku.

// nahrada dat v mailu
$mail = $wpcf7->prop(‚mail‘);

if($poc > $val): // objednano vic kusu, nez je na sklade, nahradim REPLACER textem
$mail[‚pocet‘] = $val; // snizim objednany pocet
// doplnim upozorneni do mailu
// Find/replace the „special“ tag as defined in your CF7 email body
$mail[‚body‘] = str_replace(‚REPLACER‘, „Jelikož jste objednali větší počet („.$poc.“ ks), než bylo aktuálně k dispozici skladem („.$val.“ ks), bude objednaný počet snížen na dostupné množství.\n“, $mail[‚body‘]);
else: // odstrani REPLACER string
$mail[‚body‘] = str_replace(‚REPLACER‘, „“, $mail[‚body‘]);
endif;

// Save the email body
$wpcf7->set_properties(array(„mail“ => $mail));

// return current cf7 instance
return $wpcf7;
}
}
add_action(‚wpcf7_before_send_mail‘, ‚wpcf7_change_mail‘);

### Action performed WHEN the mail is sent by CF7
function cf7_decrement_order_counter($form){
$formid = $form->id; // gets current form id
if ($formid == ‚384‘) {
// $wpcf7 = WPCF7_ContactForm::get_current(); // get current FORM instance
$wpcf7data = WPCF7_Submission::get_instance(); // // get current SUBMISSION instance
if ($wpcf7data) {
$formData = $wpcf7data->get_posted_data();
}
$poc = $formData[‚pocet‘]; // nacte hodnotu z prave odeslaneho formulare
$val = get_option(CF7_COUNTER, POCNAB) – $poc; // kdyz neexistuje option v db, vytvori a naplni ji startovnim poctem snizenym o odeslanou objednavku.
update_option(CF7_COUNTER, $val); // Update the settings with the new count
update_option(CF7_LASTORD, $poc); // Update the settings with the new count
}
}
add_action(‚wpcf7_mail_sent‘, ‚cf7_decrement_order_counter‘);

### zmena poctu objednanych kusu v databazi odeslanych formularu (Contact Form DB)
function change_cfdb_value($formData){
$formName = ‚A514‘;
if ($formData && $formName == $formData->title) {
$poc = $formData->posted_data[‚pocet‘];
$val = get_option(CF7_COUNTER, POCNAB);
if($poc > $val): // objednano vic kusu, nez je na sklade
$formData->posted_data[‚dodavka‘] = $val;
else:
$formData->posted_data[‚dodavka‘] = $poc;
endif;
}
return $formData;
}
add_filter(‚cfdb_form_data‘, ‚change_cfdb_value‘);

### Change content of Ordering Page
function formRemover($content) {
if(!is_feed() && !is_admin() && is_page(381)) {
$val = get_option(CF7_COUNTER);
if($val == 0):
$content = str_replace(‚

Tak neváhejte!

‚, ‚

Prodej byl ukončen.

‚, $content);
else:
$content = str_replace(‚

‚, ‚

Objednávkový formulář

Chyba: Kontaktní formulář nebyl nalezen.

‚, $content);
endif;
}
return $content;
}
add_filter (‚the_content‘, ‚formRemover‘);

### Change content of Thank You Page
function orderAlert($content) {
if(!is_feed() && !is_admin() && is_page(385)) {
$val = get_option(CF7_COUNTER, POCNAB);
$poc = get_option(CF7_LASTORD, 0);
$roz = $poc-$val;
if($val <= 0): $content = str_replace('REPLACER', '

Díky za objednávku.

Jelikož jste objednali větší počet kusů, než bylo aktuálně k dispozici skladem, byl Vámi objednaný počet snížen.

Na adresu, kterou jste uvedli ve formuláři, byl zaslán potvrzující e-mail.

‚, $content);
update_option(CF7_COUNTER, 0); // vynulovani pocitadla
update_option(CF7_LASTORD, 0); // vynulovani pocitadla
else:
$content = str_replace(‚REPLACER‘, ‚

Díky za objednávku.

Na adresu, kterou jste uvedli ve formuláři, byl zaslán potvrzující e-mail.

‚, $content);
endif;
}
return $content;
}
add_filter (‚the_content‘, ‚orderAlert‘);

### pridani odkazu na blog page k excerptum
function excerpt_read_more_link($output) {
global $post;
return $output . ‚Chyba: Kontaktní formulář nebyl nalezen.

‚, $content);
endif;
}
return $content;
}
add_filter (‚the_content‘, ‚formRemover‘);

### Change content of Thank You Page
function orderAlert($content) {
if(!is_feed() && !is_admin() && is_page(72)) {
$val = get_option(CF7_COUNTER, POCNAB);
$poc = get_option(CF7_LASTORD, 0);
$roz = $poc-$val;
if($val <= 0): $content = str_replace('REPLACER', '

Díky za objednávku.

Jelikož jste objednali větší počet kusů, než bylo aktuálně k dispozici skladem, byl Vámi objednaný počet snížen.

Na adresu, kterou jste uvedli ve formuláři, byl zaslán potvrzující e-mail.

‚, $content);
update_option(CF7_COUNTER, 0); // vynulovani pocitadla
update_option(CF7_LASTORD, 0); // vynulovani pocitadla
else:
$content = str_replace(‚REPLACER‘, ‚

Díky za objednávku.

Na adresu, kterou jste uvedli ve formuláři, byl zaslán potvrzující e-mail.

‚, $content);
endif;
}
return $content;
}
add_filter (‚the_content‘, ‚orderAlert‘);
\—

[/private]

Ve verzi CF7 4 a vyšší se způsob přebírání dat z formuláře změnil:
/—code php
/* WPCF7_ContactForm object no longer has a posted_data property. */
$posted_data = $contact_form->posted_data; // Tohle už nefunguje

/* Use WPCF7_Submission object’s get_posted_data() method to get it. */
$submission = WPCF7_Submission::get_instance();

if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
\—

Změna umístění pozice obsahového editoru nebo metaboxu v administraci

**How to Move and Position The WordPress WYSIWYG Visual Editor**
„http://www.farinspace.com/move-and-position-wordpress-visual-editor/“:http://www.farinspace.com/move-and-position-wordpress-visual-editor/

**Move excerpt meta box to above content editor**
„http://wordpress.stackexchange.com/questions/137571/move-excerpt-meta-box-to-above-content-editor“:http://wordpress.stackexchange.com/questions/137571/move-excerpt-meta-box-to-above-content-editor

**Move custom meta box above editor**
„http://wordpress.org/support/topic/move-custom-meta-box-above-editor“:http://wordpress.org/support/topic/move-custom-meta-box-above-editor

WordPress návody přímo v administraci

**LifeGuard+**
„http://wplifeguard.com/lifeguard-plugin/“:http://wplifeguard.com/lifeguard-plugin/

The LifeGuard+ Assistant plugin puts WordPress video tutorials right into a WordPress Dashboard. Gone are the days where WordPress developers have to teach each new client how to use WordPress. Now all that needs to be done is install LifeGuard+ Assistant on all new client WordPress projects, and they can learn how to use WordPress by watching our thorough WordPress tutorials!

76 užitečných tipů

– WordPress Shortcodes
– WordPress Permalinks Outside of the Loop
– Custom Message to Returning Visitors
– Recently Updated Posts and Pages
– Custom Content to Search Engine Visitors
– Last Modified Time and Date for Posts
– Display Total Number of Trackbacks and Pingbacks
– Display Recently Registered Users
– List all of Your Site’s Posts
– List WordPress User Information
– Display List of Scheduled Posts
– Display Private Posts to Logged-in Users
– Display Posts from Exactly One Year Ago
– Custom CSS Styles for Recent Posts
– New WordPress-2.7 Comments Loop
– Backwards-Compatible Comment Templates
– Disable WordPress Post Revisions
– Limit WordPress Post Revisions
– Remove WordPress Post Revisions from the Database
– Reduce Comment Spam by Blocking No-Referrer Requests
– Prevent Google Analytics from Tracking Admin Pages
– Meta Descriptions without a Plugin
– Differentiate Between Posts Depending on Presence of Excerpt
– Modify the wp_options Table via the WordPress Admin
– Alternate Comment Styles
– Automatically Remove Code Mistakes in Posts
– Automatically Disable Comments and Trackbacks in Old Posts
– Access Post Data Outside the Loop
– Display Posts for a Specified Time Period
– Unique Single Post Templates for Different Categories
– Display Performance Statistics for WordPress Pages
– Custom Post Thumbnails in Two Steps
– Highlight Author Comments
– Easy Random Posts
– Display Dates for Groups of Posts
– Display a Sticky Post in the Sidebar
– Display Latest Comments without a Plugin
– Display Most Commented Posts without a Plugin
– Change Permalinks from Date-Based to Post-Date Only
– Test for Sub-Pages
– Multiple Widgetizable Sidebars
– Remove Fancy Quotes from Comments
– Display a List of All Untagged Posts
– Easy Display of Custom Headers, Footers, and Sidebars
– A Better Way for Users to Logout
– Display a Custom Message on a Specific Date
– Display Three Columns of Posts
– Disable WordPress Search Functionality
– Display Posts with Specific Custom Fields
– How to Number Your Comments, Pingbacks, & Trackbacks in 2.7+
– How to Number Your Comments Using the Classic Loop
– Invite Readers to Comment via Feed
– Display the Total Number of Users for Your Blog
– Automatically Insert Content into Your WordPress Post Editor
– How to Prevent Duplicate Content
– Conditionally Display Full Posts or Excerpts
– Display Related Posts without a Plugin
– Drop-Dead Easy Styles for Author Comments
– Display Posts Upcoming Scheduled Posts
– Display Automatic TinyURLs for Your Posts
– Implement a Site-Maintenance Page for Your Blog
– Display the First Image from Each of Your Posts
– Display Most Popular Posts without a Plugin
– Automatically Highlight Search Terms
– Automatically Disable Widgets
– Display All Images from Your Post Content
– Display Category List in Two Columns
– Show Ads or Other Content Only in the First Three Posts
– A Better Way to Display Recent Comments without a Plugin
– Selectively Disable Automatic Post Formatting
– Browser Detection via WordPress’ body_class Function
– Get Post or Page Contents as a PHP Variable
– Simple Example of How to Use WordPress Cron
– Add More Default Avatar Choices to the WordPress Admin
– Add a Private Page to Your Navigation Menu
– How to Add Additional Links to wp_list_pages

„Stupid WordPress Tricks »“:http://perishablepress.com/stupid-wordpress-tricks/