tracking-code-manager
Last commit date
assets
11 years ago
includes
11 years ago
languages
11 years ago
logs
11 years ago
templates
11 years ago
readme.txt
11 years ago
screenshot-1.png
11 years ago
screenshot-2.png
11 years ago
screenshot-3.png
11 years ago
screenshot-4.png
11 years ago
screenshot-5.png
11 years ago
screenshot-6.png
11 years ago
tracking-code-manager.php
11 years ago
tracking-code-manager.php
239 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Tracking Code Manager |
| 4 | Plugin URI: http://intellywp.com/tracking-code-manager/ |
| 5 | Description: A plugin to manage ALL your tracking code and conversion pixels, simply. Compatible with Facebook Ads, Google Adwords and ALL kind of Saas tool. |
| 6 | Author: IntellyWP |
| 7 | Author URI: http://intellywp.com/ |
| 8 | Email: aleste@intellywp.com |
| 9 | Version: 1.5 |
| 10 | */ |
| 11 | define('TCM_PLUGIN_FILE',__FILE__); |
| 12 | define('TCM_PLUGIN_NAME', 'tracking-code-manager'); |
| 13 | define('TCM_PLUGIN_VERSION', '1.5'); |
| 14 | define('TCM_PLUGIN_AUTHOR', 'IntellyWP'); |
| 15 | define('TCM_PLUGIN_ROOT', dirname(__FILE__).'/'); |
| 16 | define('TCM_PLUGIN_IMAGES', plugins_url( 'assets/images/', __FILE__ )); |
| 17 | |
| 18 | define('TCM_LOGGER', FALSE); |
| 19 | |
| 20 | define('TCM_QUERY_POSTS_OF_TYPE', 1); |
| 21 | define('TCM_QUERY_POST_TYPES', 2); |
| 22 | |
| 23 | define('TCM_INTELLYWP_SITE', 'http://www.intellywp.com/'); |
| 24 | define('TCM_INTELLYWP_RECEIVER', TCM_INTELLYWP_SITE.'wp-content/plugins/intellywp-manager/data.php'); |
| 25 | define('TCM_PAGE_FAQ', TCM_INTELLYWP_SITE.'tracking-code-manager'); |
| 26 | define('TCM_PAGE_PREMIUM', TCM_INTELLYWP_SITE.'tracking-code-manager'); |
| 27 | define('TCM_PAGE_MANAGER', admin_url().'options-general.php?page='.TCM_PLUGIN_NAME); |
| 28 | |
| 29 | define('TCM_POSITION_HEAD', 0); |
| 30 | define('TCM_POSITION_BODY', 1); |
| 31 | define('TCM_POSITION_FOOTER', 2); |
| 32 | |
| 33 | define('TCM_TAB_EDITOR', 'editor'); |
| 34 | define('TCM_TAB_EDITOR_URI', TCM_PAGE_MANAGER.'&tab='.TCM_TAB_EDITOR); |
| 35 | define('TCM_TAB_MANAGER', 'manager'); |
| 36 | define('TCM_TAB_MANAGER_URI', TCM_PAGE_MANAGER.'&tab='.TCM_TAB_MANAGER); |
| 37 | define('TCM_TAB_SETTINGS', 'settings'); |
| 38 | define('TCM_TAB_SETTINGS_URI', TCM_PAGE_MANAGER.'&tab='.TCM_TAB_SETTINGS); |
| 39 | define('TCM_TAB_ABOUT', 'about'); |
| 40 | define('TCM_TAB_ABOUT_URI', TCM_PAGE_MANAGER.'&tab='.TCM_TAB_ABOUT); |
| 41 | |
| 42 | include_once(dirname(__FILE__).'/includes/class-TCM-cron.php'); |
| 43 | include_once(dirname(__FILE__).'/includes/class-TCM-tracking.php'); |
| 44 | include_once(dirname(__FILE__).'/includes/class-TCM-logger.php'); |
| 45 | include_once(dirname(__FILE__).'/includes/class-TCM-manager.php'); |
| 46 | include_once(dirname(__FILE__).'/includes/class-TCM-form.php'); |
| 47 | include_once(dirname(__FILE__).'/includes/class-TCM-options.php'); |
| 48 | include_once(dirname(__FILE__).'/includes/class-TCM-check.php'); |
| 49 | include_once(dirname(__FILE__).'/includes/class-TCM-utils.php'); |
| 50 | include_once(dirname(__FILE__).'/includes/class-TCM-language.php'); |
| 51 | |
| 52 | global $tcm; |
| 53 | $tcm=new TCM_Singleton(); |
| 54 | |
| 55 | include_once(dirname(__FILE__).'/includes/actions.php'); |
| 56 | include_once(dirname(__FILE__).'/includes/core.php'); |
| 57 | include_once(dirname(__FILE__).'/includes/install.php'); |
| 58 | include_once(dirname(__FILE__).'/includes/uninstall.php'); |
| 59 | |
| 60 | include_once(dirname(__FILE__).'/includes/admin/about.php'); |
| 61 | include_once(dirname(__FILE__).'/includes/admin/editor.php'); |
| 62 | include_once(dirname(__FILE__).'/includes/admin/feedback.php'); |
| 63 | include_once(dirname(__FILE__).'/includes/admin/metabox.php'); |
| 64 | include_once(dirname(__FILE__).'/includes/admin/settings.php'); |
| 65 | include_once(dirname(__FILE__).'/includes/admin/manager.php'); |
| 66 | |
| 67 | class TCM_Singleton { |
| 68 | var $Lang; |
| 69 | var $Utils; |
| 70 | var $Form; |
| 71 | var $Check; |
| 72 | var $Options; |
| 73 | var $Logger; |
| 74 | var $Cron; |
| 75 | var $Tracking; |
| 76 | var $Manager; |
| 77 | |
| 78 | function __construct() { |
| 79 | $this->Lang=new TCM_Language(); |
| 80 | $this->Lang->load('tcm', TCM_PLUGIN_ROOT.'languages/TCM.txt'); |
| 81 | |
| 82 | $this->Utils=new TCM_Utils(); |
| 83 | $this->Form=new TCM_Form(); |
| 84 | $this->Check=new TCM_Check(); |
| 85 | $this->Options=new TCM_Options(); |
| 86 | $this->Logger=new TCM_Logger(); |
| 87 | $this->Cron=new TCM_Cron(); |
| 88 | $this->Tracking=new TCM_Tracking(); |
| 89 | $this->Manager=new TCM_Manager(); |
| 90 | } |
| 91 | } |
| 92 | //from Settings_API_Tabs_Demo_Plugin |
| 93 | class TCM_Tabs { |
| 94 | private $tabs = array(); |
| 95 | |
| 96 | function __construct() { |
| 97 | add_action('admin_menu', array(&$this, 'attachMenu')); |
| 98 | add_filter('plugin_action_links', array(&$this, 'pluginActions'), 10, 2); |
| 99 | add_action('admin_enqueue_scripts', array(&$this, 'enqueueScripts')); |
| 100 | } |
| 101 | |
| 102 | function attachMenu() { |
| 103 | global $tcm; |
| 104 | $name='Tracking Code Manager'; |
| 105 | add_submenu_page('options-general.php' |
| 106 | , $name, $name |
| 107 | , 'edit_posts', TCM_PLUGIN_NAME, array(&$this, 'showTabPage')); |
| 108 | } |
| 109 | function pluginActions($links, $file) { |
| 110 | global $tcm; |
| 111 | if($file==TCM_PLUGIN_NAME.'/'.TCM_PLUGIN_NAME.'.php'){ |
| 112 | $settings = "<a href='".TCM_PAGE_MANAGER."'>" . $tcm->Lang->L('Settings') . '</a> '; |
| 113 | $premium = "<a href='".TCM_PAGE_PREMIUM."'>" . $tcm->Lang->L('PREMIUM') . '</a> '; |
| 114 | $links = array_merge(array($settings, $premium), $links); |
| 115 | } |
| 116 | return $links; |
| 117 | } |
| 118 | function enqueueScripts() { |
| 119 | wp_enqueue_script('jquery'); |
| 120 | wp_enqueue_script('suggest'); |
| 121 | wp_enqueue_script('jquery-ui-autocomplete'); |
| 122 | |
| 123 | wp_enqueue_style('tcm-css', plugins_url('assets/css/style.css', __FILE__ )); |
| 124 | wp_enqueue_style('tcm-select2-css', plugins_url('assets/deps/select2-3.5.2/select2.css', __FILE__ )); |
| 125 | wp_enqueue_script('tcm-select2-js', plugins_url('assets/deps/select2-3.5.2/select2.min.js', __FILE__ )); |
| 126 | wp_enqueue_script('tcm-starrr-js', plugins_url('assets/deps/starrr/starrr.js', __FILE__ )); |
| 127 | |
| 128 | wp_register_script('tcm-autocomplete', plugins_url('assets/js/tcm-autocomplete.js', __FILE__ ), array('jquery', 'jquery-ui-autocomplete'), '1.0', FALSE); |
| 129 | wp_localize_script('tcm-autocomplete', 'TCMAutocomplete', array('url' => admin_url('admin-ajax.php') |
| 130 | )); |
| 131 | wp_enqueue_script('tcm-autocomplete'); |
| 132 | } |
| 133 | |
| 134 | function showTabPage() { |
| 135 | global $tcm; |
| 136 | |
| 137 | $id=intval($tcm->Utils->qs('id', 0)); |
| 138 | $tab=$tcm->Utils->qs('tab', TCM_TAB_MANAGER); |
| 139 | |
| 140 | if($id>0 || $tcm->Manager->rc()>0) { |
| 141 | $this->tabs[TCM_TAB_EDITOR]=$tcm->Lang->L($id>0 ? 'Edit' : 'New'); |
| 142 | } elseif($tab==TCM_TAB_EDITOR) { |
| 143 | $tab=TCM_TAB_MANAGER; |
| 144 | } |
| 145 | $this->tabs[TCM_TAB_MANAGER]=$tcm->Lang->L('Manager'); |
| 146 | $this->tabs[TCM_TAB_SETTINGS]=$tcm->Lang->L('Settings'); |
| 147 | $this->tabs[TCM_TAB_ABOUT]=$tcm->Lang->L('About'); |
| 148 | |
| 149 | ?> |
| 150 | <div class="wrap" style="margin:5px;"> |
| 151 | <?php |
| 152 | $this->showTabs(); |
| 153 | $header=''; |
| 154 | switch ($tab) { |
| 155 | case TCM_TAB_EDITOR: |
| 156 | $header=($id>0 ? 'Edit' : 'Add'); |
| 157 | break; |
| 158 | case TCM_TAB_MANAGER: |
| 159 | $header='Manager'; |
| 160 | break; |
| 161 | case TCM_TAB_SETTINGS: |
| 162 | $header='Settings'; |
| 163 | break; |
| 164 | case TCM_TAB_ABOUT: |
| 165 | $header='About'; |
| 166 | break; |
| 167 | } |
| 168 | |
| 169 | if($tcm->Lang->H($header.'Title')) { ?> |
| 170 | <h2><?php $tcm->Lang->P($header . 'Title') ?></h2> |
| 171 | <?php if ($tcm->Lang->H($header . 'Subtitle')) { ?> |
| 172 | <div><?php $tcm->Lang->P($header . 'Subtitle') ?></div> |
| 173 | <?php } ?> |
| 174 | <br/> |
| 175 | <?php } |
| 176 | |
| 177 | switch ($tab) { |
| 178 | case TCM_TAB_EDITOR: |
| 179 | tcm_ui_editor(); |
| 180 | break; |
| 181 | case TCM_TAB_MANAGER: |
| 182 | tcm_ui_manager(); |
| 183 | if($tcm->Manager->count()>0) { |
| 184 | tcm_ui_feedback(); |
| 185 | } |
| 186 | break; |
| 187 | case TCM_TAB_SETTINGS: |
| 188 | tcm_ui_settings(); |
| 189 | break; |
| 190 | case TCM_TAB_ABOUT: |
| 191 | tcm_ui_about(); |
| 192 | tcm_ui_feedback(); |
| 193 | break; |
| 194 | } ?> |
| 195 | </div> |
| 196 | <?php } |
| 197 | |
| 198 | function showTabs() { |
| 199 | global $tcm; |
| 200 | $tab=$tcm->Check->of('tab', TCM_TAB_MANAGER); |
| 201 | |
| 202 | ?> |
| 203 | <h2 class="nav-tab-wrapper" style="float:left; width:97%;"> |
| 204 | <?php |
| 205 | foreach ($this->tabs as $k=>$v) { |
| 206 | $active = ($tab==$k ? 'nav-tab-active' : ''); |
| 207 | ?> |
| 208 | <a style="float:left" class="nav-tab <?php echo $active?>" href="?page=<?php echo TCM_PLUGIN_NAME?>&tab=<?php echo $k?>"><?php echo $v?></a> |
| 209 | <?php |
| 210 | } |
| 211 | ?> |
| 212 | <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css"> |
| 213 | <style> |
| 214 | .starrr {display:inline-block} |
| 215 | .starrr i{font-size:16px;padding:0 1px;cursor:pointer;color:#2ea2cc;} |
| 216 | </style> |
| 217 | <div style="float:right; display:none;" id="rate-box"> |
| 218 | <span style="font-weight:700; font-size:13px; color:#555;"><?php $tcm->Lang->P('Rate us')?></span> |
| 219 | <div id="tcm-rate" class="starrr" data-connected-input="tcm-rate-rank"></div> |
| 220 | <input type="hidden" id="tcm-rate-rank" name="tcm-rate-rank" value="5" /> |
| 221 | |
| 222 | </div> |
| 223 | <script> |
| 224 | jQuery(function() { |
| 225 | jQuery(".starrr").starrr(); |
| 226 | jQuery('#tcm-rate').on('starrr:change', function(e, value){ |
| 227 | var url='https://wordpress.org/support/view/plugin-reviews/tracking-code-manager?rate=5#postform'; |
| 228 | window.open(url); |
| 229 | }); |
| 230 | jQuery('#rate-box').show(); |
| 231 | }); |
| 232 | </script> |
| 233 | </h2> |
| 234 | <div style="clear:both;"></div> |
| 235 | <?php } |
| 236 | } |
| 237 | |
| 238 | $tcmTabs=new TCM_Tabs(); |
| 239 |