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
/* Konkretes Beispiel: Metabox mit einem 2ter Autor wird angezeigt und es wird in das custom field "2nd author" der Wert eingetragen (so dass man den Wert theoretisch auch über Bearbeitung der custom field metabox (als Teil des WordPress Cores) bearbeiten könnte). | |
(Wenn man das Custom Field "_2nd author" nennen würde, dann würde es dort nicht angezeigt werden -> Präfix _ sorgt dafür, dass es nur in der Datenbank angezeigt wird und nicht in der Metabox der custom fields.) */ | |
// Add a Metabox to the backend | |
function add_nxt_author_meta_box() { | |
add_meta_box("nxt-author-meta-box", "2nd Author", "nxt_author_meta_box_markup", "post", "side", "high", null); | |
} | |
add_action("add_meta_boxes", "add_nxt_author_meta_box"); |
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
// Add a new dashboard widget to WordPress | |
function nextab_add_dashboard_widgets() { | |
wp_add_dashboard_widget('nxt_dev_info', 'Designer & Developer Info', 'nextab_theme_info'); | |
} | |
add_action('wp_dashboard_setup', 'nextab_add_dashboard_widgets' ); | |
// Populate dashboard widget data | |
function nextab_theme_info() { | |
echo '<ul> | |
<li><strong>Entwickelt von:</strong> <a href="http://www.nextab.de">nexTab.de</a></li> | |
<li><strong>E-Mail:</strong> <a href="mailto:[email protected]">[email protected]</a></li> |
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 output_my_custom_field($atts, $content = null) { | |
$a = shortcode_atts([ | |
"field" => "_my_custom_field_name", | |
"title" => "Videodauer:", | |
"class" => "custom_field_value_wrapper", | |
], $atts); | |
$return_string = ''; | |
if(get_post_meta(get_the_ID(), $a["field"], true) != '') { | |
$my_custom_field_value = get_post_meta(get_the_ID(), $a["field"], true); | |
$return_string = '<div class="' . $a["class"] . '"><strong>' . $a["title"] . '</strong> ' . $my_custom_field_value . '</div>'; |
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 meine_blurb_function($atts, $content = null) { | |
$a = shortcode_atts([ | |
'title' => 'Mein Titel', | |
'icon' => '%%29%%', | |
], $atts); | |
return do_shortcode('[et_pb_blurb title="' . $a["title"] . '" _builder_version="4.9.4" _module_preset="default" use_icon="on" font_icon="' . $a["icon"] . '" hover_enabled="0" sticky_enabled="0"]' . $content . '[/et_pb_blurb])'; | |
} | |
add_shortcode('mein_blurb', 'meine_blurb_function'); | |
/* Anwendung: |
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
// get your custom posts ids as an array | |
$posts = get_posts(array( | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'fields' => 'ids', | |
) | |
); | |
//loop over each post | |
foreach($posts as $p){ |
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
/* Funktionsweise: Ein Link auf ein Element mit der Klasse .fake-button sorgt dafür, dass das mit der href referenzierte Element (z. B. href="#meine-id")" mit der entsprechenden CSS ID (im Beispiel also ""#meine-id") nach einem Klick automatisch die Klasse "active" erhält. | |
Theoretisch ist die Logik beispielsweise erweiterbar, indem man die Klasse über einen .close-Button wieder wegnimmt. | |
Anwendungsbeispiel: | |
1.) Button: | |
<div class="fake-button" href="#reveal-info" title="Anklicken, um mehr zu erfahren">Mehr Informationen</a> |
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
// Übergabe der Produkt-ID bei Funktionsaufruf; es wird als Rückgabe mitgeteilt, ob der aktuell eingeloggte Benutzer ein bestimmtes DigiMember Produkt erworben hat (true bei ja). | |
function nxt_check_dm_access($product_id = 2) { | |
global $wpdb; | |
$user_id = get_current_user_id(); | |
$result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}digimember_user_product WHERE product_id = $product_id and is_active = 'Y' and user_id = $user_id"); | |
// echo '<pre>'; print_r($result); echo '</pre>'; | |
// echo '<pre>'; print_r("SELECT * FROM {$wpdb->prefix}digimember_user_product WHERE product_id = $product_id and is_active = 'Y' and user_id = $user_id"); echo '</pre>'; | |
if($result) { | |
return true; |