admin
4 years ago
classes
4 years ago
actions.php
4 years ago
core.php
4 years ago
install.php
4 years ago
uninstall.php
4 years ago
core.php
74 lines
| 1 | <?php |
| 2 | //per agganciarsi ogni volta che viene scritto un contenuto |
| 3 | add_filter('wp_head', 'tcmp_head', get_option('TCM_HookPriority', TCMP_HOOK_PRIORITY_DEFAULT)); |
| 4 | function tcmp_head(){ |
| 5 | global $post, $tcmp; |
| 6 | |
| 7 | $tcmp->Options->setPostShown(NULL); |
| 8 | if($post && isset($post->ID) && (is_page($post->ID) || is_single($post->ID))) { |
| 9 | $tcmp->Options->setPostShown($post); |
| 10 | $tcmp->Log->info('POST ID=%s IS SHOWN', $post->ID); |
| 11 | } |
| 12 | |
| 13 | $tcmp->BodyWritten = false; |
| 14 | |
| 15 | //future development |
| 16 | //is_archive(); |
| 17 | //is_post_type_archive(); |
| 18 | //is_post_type_hierarchical(); |
| 19 | //is_attachment(); |
| 20 | $tcmp->Manager->writeCodes(TCMP_POSITION_HEAD); |
| 21 | } |
| 22 | |
| 23 | add_action('wp_body_open', 'tcmp_body', get_option('TCM_HookPriority', TCMP_HOOK_PRIORITY_DEFAULT)); |
| 24 | function tcmp_body() |
| 25 | { |
| 26 | global $tcmp; |
| 27 | |
| 28 | $tcmp->Manager->writeCodes(TCMP_POSITION_BODY); |
| 29 | $tcmp->BodyWritten = true; |
| 30 | } |
| 31 | |
| 32 | add_action('wp_footer', 'tcmp_footer', get_option('TCM_HookPriority', TCMP_HOOK_PRIORITY_DEFAULT)); |
| 33 | function tcmp_footer() { |
| 34 | global $tcmp; |
| 35 | |
| 36 | if (!$tcmp->BodyWritten) { |
| 37 | // this is a fallback if wp_body_open() is not called by the theme |
| 38 | $tcmp->Manager->writeCodes(TCMP_POSITION_BODY); |
| 39 | } |
| 40 | |
| 41 | $tcmp->Manager->writeCodes(TCMP_POSITION_CONVERSION); |
| 42 | $tcmp->Manager->writeCodes(TCMP_POSITION_FOOTER); |
| 43 | } |
| 44 | |
| 45 | //volendo funziona anche con gli shortcode |
| 46 | add_shortcode('tcmp', 'tcmp_shortcode'); |
| 47 | add_shortcode('tcm', 'tcmp_shortcode'); |
| 48 | function tcmp_shortcode($atts, $content='') { |
| 49 | global $tcmp; |
| 50 | extract(shortcode_atts(array('id' => false), $atts)); |
| 51 | |
| 52 | if (!isset($id) || !$id) { |
| 53 | return ''; |
| 54 | } |
| 55 | |
| 56 | $snippet=$tcmp->Manager->get($id, true); |
| 57 | return $snippet['code']; |
| 58 | } |
| 59 | |
| 60 | function tcmp_ui_first_time() { |
| 61 | global $tcmp; |
| 62 | if($tcmp->Options->isShowActivationNotice()) { |
| 63 | //$tcmp->Options->pushSuccessMessage('FirstTimeActivation'); |
| 64 | //$tcmp->Options->writeMessages(); |
| 65 | $tcmp->Options->setShowActivationNotice(FALSE); |
| 66 | } |
| 67 | } |
| 68 | function tcmp_admin_footer() { |
| 69 | global $tcmp; |
| 70 | if($tcmp->Lang->bundle->autoPush && TCMP_AUTOSAVE_LANG) { |
| 71 | $tcmp->Lang->bundle->store(TCMP_PLUGIN_DIR.'languages/Lang.txt'); |
| 72 | } |
| 73 | } |
| 74 | add_filter('admin_footer', 'tcmp_admin_footer'); |