PluginProbe
Tracking Code Manager / 1.5
Tracking Code Manager v1.5
2.8.0 2.7.0 trunk 1.11.8 1.11.9 1.12.0 1.12.1 1.12.2 1.12.3 1.4 1.5 2.0.0 2.0.1 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.2.0 All 29 releases
← All changes | includes/core.php +26 -90 trunk1.5 View file →
@@ -1,90 +1,26 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) exit;
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 ) && $post->ID > 0 ) {
9 - $tcmp->options->setPostShown( $post );
10 - $tcmp->log->info( 'POST ID=%s IS SHOWN', $post->ID );
11 - }
12 -
13 - $tcmp->body_written = false;
14 -
15 - //future development
16 - //is_archive();
17 - //is_post_type_archive();
18 - //is_post_type_hierarchical();
19 - //is_attachment();
20 - $tcmp->manager->write_codes( 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 - global $tcmp;
26 -
27 - $tcmp->manager->write_codes( TCMP_POSITION_BODY );
28 - $tcmp->body_written = true;
29 -}
30 -
31 -add_action( 'wp_footer', 'tcmp_footer', get_option( 'TCM_HookPriority', TCMP_HOOK_PRIORITY_DEFAULT ) );
32 -function tcmp_footer() {
33 - global $tcmp;
34 -
35 - if ( ! $tcmp->body_written ) {
36 - // this is a fallback if wp_body_open() is not called by the theme
37 - $tcmp->manager->write_codes( TCMP_POSITION_BODY );
38 - }
39 -
40 - $tcmp->manager->write_codes( TCMP_POSITION_CONVERSION );
41 - $tcmp->manager->write_codes( TCMP_POSITION_FOOTER );
42 -
43 - if ( $tcmp->options->getModifySuperglobalVariable() ) {
44 - if ( function_exists( 'wp_cache_set_home' ) ) {
45 - unset( $_POST );
46 - }
47 - }
48 -}
49 -
50 -//volendo funziona anche con gli shortcode
51 -add_shortcode( 'tcmp', 'tcmp_shortcode' );
52 -add_shortcode( 'tcm', 'tcmp_shortcode' );
53 -function tcmp_shortcode( $atts, $content = '' ) {
54 - global $tcmp;
55 - // Assign explicitly instead of extract() on external input (see F-13).
56 - $atts = shortcode_atts( array( 'id' => false ), $atts );
57 - $id = $atts['id'];
58 -
59 - if ( ! $id ) {
60 - return '';
61 - }
62 -
63 - $snippet = $tcmp->manager->get( $id, true );
64 - if ( ! is_array( $snippet ) || ! isset( $snippet['code'] ) ) {
65 - return '';
66 - }
67 -
68 - // Run the snippet through the same output path as write_codes() instead of
69 - // returning it raw, so the shortcode and the normal injection path cannot
70 - // diverge (F-05). Note that this equalises the two paths; it does not make
71 - // the shortcode safe to expose to lower-privileged authors, because the
72 - // whitelist esc_js_code() applies permits <script> by design.
73 - return $tcmp->manager->esc_js_code( $snippet['code'] );
74 -}
75 -
76 -function tcmp_ui_first_time() {
77 - global $tcmp;
78 - if ( $tcmp->options->isShowActivationNotice() ) {
79 - //$tcmp->options->pushSuccessMessage('FirstTimeActivation');
80 - //$tcmp->options->writeMessages();
81 - $tcmp->options->setShowActivationNotice( false );
82 - }
83 -}
84 -function tcmp_admin_footer() {
85 - global $tcmp;
86 - if ( $tcmp->lang->bundle->autoPush && TCMP_AUTOSAVE_LANG ) {
87 - $tcmp->lang->bundle->store( TCMP_PLUGIN_DIR . 'languages/Lang.txt' );
88 - }
89 -}
90 -add_filter( 'admin_footer', 'tcmp_admin_footer' );
1 +<?php
2 +//per agganciarsi ogni volta che viene scritto un contenuto
3 +add_filter('wp_head', 'tcm_head');
4 +function tcm_head(){
5 + global $post, $tcm;
6 +
7 + $tcm->Options->setPostShown(NULL);
8 + if(is_page($post->ID) || is_single($post->ID)) {
9 + $tcm->Options->setPostShown($post);
10 + $tcm->Logger->info('POST ID=%s IS SHOWN', $post->ID);
11 + }
12 +
13 + //future development
14 + //is_archive();
15 + //is_post_type_archive();
16 + //is_post_type_hierarchical();
17 + //is_attachment();
18 + $tcm->Manager->writeCodes(TCM_POSITION_HEAD);
19 +}
20 +add_action('wp_footer', 'tcm_footer');
21 +function tcm_footer() {
22 + global $tcm;
23 + //there isn't a hook when <BODY> starts
24 + $tcm->Manager->writeCodes(TCM_POSITION_BODY);
25 + $tcm->Manager->writeCodes(TCM_POSITION_FOOTER);
26 +}