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
80 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 | if ($tcmp->Options->getModifySuperglobalVariable()) { |
| 45 | if (function_exists('wp_cache_set_home')) { |
| 46 | unset($_POST); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | //volendo funziona anche con gli shortcode |
| 52 | add_shortcode('tcmp', 'tcmp_shortcode'); |
| 53 | add_shortcode('tcm', 'tcmp_shortcode'); |
| 54 | function tcmp_shortcode($atts, $content='') { |
| 55 | global $tcmp; |
| 56 | extract(shortcode_atts(array('id' => false), $atts)); |
| 57 | |
| 58 | if (!isset($id) || !$id) { |
| 59 | return ''; |
| 60 | } |
| 61 | |
| 62 | $snippet=$tcmp->Manager->get($id, true); |
| 63 | return $snippet['code']; |
| 64 | } |
| 65 | |
| 66 | function tcmp_ui_first_time() { |
| 67 | global $tcmp; |
| 68 | if($tcmp->Options->isShowActivationNotice()) { |
| 69 | //$tcmp->Options->pushSuccessMessage('FirstTimeActivation'); |
| 70 | //$tcmp->Options->writeMessages(); |
| 71 | $tcmp->Options->setShowActivationNotice(FALSE); |
| 72 | } |
| 73 | } |
| 74 | function tcmp_admin_footer() { |
| 75 | global $tcmp; |
| 76 | if($tcmp->Lang->bundle->autoPush && TCMP_AUTOSAVE_LANG) { |
| 77 | $tcmp->Lang->bundle->store(TCMP_PLUGIN_DIR.'languages/Lang.txt'); |
| 78 | } |
| 79 | } |
| 80 | add_filter('admin_footer', 'tcmp_admin_footer'); |