| @@ -1,315 +1,247 @@ | ||
| 1 | -<?php | |
| 2 | -function tcmp_notice_pro_features() { | |
| 3 | - global $tcmp; | |
| 4 | - ?> | |
| 5 | - <br/> | |
| 6 | - <div class="message updated below-h2 iwp"> | |
| 7 | - <div style="height:10px;"></div> | |
| 8 | - <?php | |
| 9 | - $i = 1; | |
| 10 | - while ( $tcmp->lang->H( 'Notice.ProHeader' . $i ) ) { | |
| 11 | - $tcmp->lang->P( 'Notice.ProHeader' . $i ); | |
| 12 | - echo '<br/>'; | |
| 13 | - ++$i; | |
| 14 | - } | |
| 15 | - $i = 1; | |
| 16 | - ?> | |
| 17 | - <br/> | |
| 18 | - <?php | |
| 19 | - | |
| 20 | - /*$options = array('public' => TRUE, '_builtin' => FALSE); | |
| 21 | - $q=get_post_types($options, 'names'); | |
| 22 | - if(is_array($q) && count($q)>0) { | |
| 23 | - sort($q); | |
| 24 | - $q=implode(', ', $q); | |
| 25 | - $q='(<b>'.$q.'</b>)'; | |
| 26 | - } else { | |
| 27 | - $q=''; | |
| 28 | - }*/ | |
| 29 | - $q = ''; | |
| 30 | - while ( $tcmp->lang->H( 'Notice.ProFeature' . $i ) ) { | |
| 31 | - ?> | |
| 32 | - <div style="clear:both; margin-top: 2px;"></div> | |
| 33 | - <div style="float:left; vertical-align:middle; height:24px; margin-right:5px; margin-top:-5px;"> | |
| 34 | - <img src="<?php echo TCMP_PLUGIN_IMAGES_URI; ?>tick.png" /> | |
| 35 | - </div> | |
| 36 | - <div style="float:left; vertical-align:middle; height:24px;"> | |
| 37 | - <?php $tcmp->lang->P( 'Notice.ProFeature' . $i, $q ); ?> | |
| 38 | - </div> | |
| 39 | - <?php | |
| 40 | - ++$i; | |
| 41 | - } | |
| 42 | - ?> | |
| 43 | - <div style="clear:both;"></div> | |
| 44 | - <div style="height:10px;"></div> | |
| 45 | - <div style="float:right;"> | |
| 46 | - <?php | |
| 47 | - $url = TCMP_PAGE_PREMIUM . '?utm_source=free-users&utm_medium=wp-cta&utm_campaign=wp-plugin'; | |
| 48 | - ?> | |
| 49 | - <a href="<?php echo esc_url( $url ); ?>" target="_blank"> | |
| 50 | - <b><?php esc_html( $tcmp->lang->P( 'Notice.ProCTA' ) ); ?></b> | |
| 51 | - </a> | |
| 52 | - </div> | |
| 53 | - <div style="height:10px; clear:both;"></div> | |
| 54 | - </div> | |
| 55 | - <br/> | |
| 56 | - <?php | |
| 57 | -} | |
| 58 | -function tcmp_ui_editor_check( $snippet ) { | |
| 59 | - global $tcmp; | |
| 60 | - | |
| 61 | - $snippet['trackMode'] = intval( $snippet['trackMode'] ); | |
| 62 | - $snippet['trackPage'] = intval( $snippet['trackPage'] ); | |
| 63 | - | |
| 64 | - $snippet['includeEverywhereActive'] = 0; | |
| 65 | - if ( TCMP_TRACK_PAGE_ALL === $snippet['trackPage'] ) { | |
| 66 | - $snippet['includeEverywhereActive'] = 1; | |
| 67 | - } | |
| 68 | - $snippet = $tcmp->manager->sanitize( $snippet['id'], $snippet ); | |
| 69 | - | |
| 70 | - if ( '' === $snippet['name'] ) { | |
| 71 | - $tcmp->options->pushErrorMessage( 'Please enter a unique name' ); | |
| 72 | - } else { | |
| 73 | - $exist = $tcmp->manager->exists( $snippet['name'] ); | |
| 74 | - if ( $exist && $exist['id'] !== $snippet['id'] ) { | |
| 75 | - //nonostante il tutto il nome deve essee univoco | |
| 76 | - $tcmp->options->pushErrorMessage( 'You have entered a name that already exists. IDs are NOT case-sensitive' ); | |
| 77 | - } | |
| 78 | - } | |
| 79 | - if ( '' === $snippet['code'] ) { | |
| 80 | - $tcmp->options->pushErrorMessage( 'Paste your HTML Tracking Code into the textarea' ); | |
| 81 | - } | |
| 82 | - | |
| 83 | - if ( TCMP_TRACK_MODE_CODE === $snippet['trackMode'] ) { | |
| 84 | - | |
| 85 | - $types = $tcmp->utils->query( TCMP_QUERY_POST_TYPES ); | |
| 86 | - if ( TCMP_TRACK_PAGE_SPECIFIC === $snippet['trackPage'] ) { | |
| 87 | - foreach ( $types as $v ) { | |
| 88 | - $include_active_key = 'includePostsOfType_' . $v['id'] . '_Active'; | |
| 89 | - $include_array_key = 'includePostsOfType_' . $v['id']; | |
| 90 | - $except_active_key = 'exceptPostsOfType_' . $v['id'] . '_Active'; | |
| 91 | - $except_array_key = 'exceptPostsOfType_' . $v['id']; | |
| 92 | - | |
| 93 | - if ( 1 === $snippet[ $include_active_key ] && 1 === $snippet[ $except_active_key ] ) { | |
| 94 | - if ( in_array( -1, $snippet[ $include_array_key ] ) && in_array( -1, $snippet[ $except_array_key ] ) ) { | |
| 95 | - $tcmp->options->pushErrorMessage( 'Error.IncludeExcludeAll', $v['name'] ); | |
| 96 | - } | |
| 97 | - } | |
| 98 | - if ( 1 === $snippet[ $include_active_key ] && 0 === count( $snippet[ $include_array_key ] ) ) { | |
| 99 | - $tcmp->options->pushErrorMessage( 'Error.IncludeSelectAtLeastOne', $v['name'] ); | |
| 100 | - } | |
| 101 | - } | |
| 102 | - | |
| 103 | - //second loop to respect the display order | |
| 104 | - foreach ( $types as $v ) { | |
| 105 | - $include_active_key = 'includePostsOfType_' . $v['id'] . '_Active'; | |
| 106 | - $include_array_key = 'includePostsOfType_' . $v['id']; | |
| 107 | - $except_active_key = 'exceptPostsOfType_' . $v['id'] . '_Active'; | |
| 108 | - $except_array_key = 'exceptPostsOfType_' . $v['id']; | |
| 109 | - | |
| 110 | - if ( 1 === $snippet[ $include_active_key ] && in_array( -1, $snippet[ $include_array_key ] ) ) { | |
| 111 | - if ( 1 === $snippet[ $except_active_key ] && 0 === count( $snippet[ $except_array_key ] ) ) { | |
| 112 | - $tcmp->options->pushErrorMessage( 'Error.ExcludeSelectAtLeastOne', $v['name'] ); | |
| 113 | - } | |
| 114 | - } | |
| 115 | - } | |
| 116 | - } else { | |
| 117 | - foreach ( $types as $v ) { | |
| 118 | - $except_active_key = 'exceptPostsOfType_' . $v['id'] . '_Active'; | |
| 119 | - $except_array_key = 'exceptPostsOfType_' . $v['id']; | |
| 120 | - | |
| 121 | - if ( isset( $snippet[ $except_active_key ] ) | |
| 122 | - && 1 === $snippet[ $except_active_key ] | |
| 123 | - && 0 === count( $snippet[ $except_array_key ] ) ) { | |
| 124 | - $tcmp->options->pushErrorMessage( 'Error.ExcludeSelectAtLeastOne', $v['name'] ); | |
| 125 | - } | |
| 126 | - } | |
| 127 | - } | |
| 128 | - } | |
| 129 | -} | |
| 130 | -function tcmp_ui_editor() { | |
| 131 | - global $tcmp; | |
| 132 | - | |
| 133 | - $tcmp->form->prefix = 'Editor'; | |
| 134 | - $id = tcmp_isqs( 'id', 0 ); | |
| 135 | - if ( 0 === $id && $tcmp->manager->is_limit_reached( false ) ) { | |
| 136 | - $tcmp->utils->redirect( TCMP_TAB_MANAGER_URI ); | |
| 137 | - } | |
| 138 | - | |
| 139 | - $snippet = $tcmp->manager->get( $id, true ); | |
| 140 | - if ( wp_verify_nonce( tcmp_qs( 'tcmp_nonce' ), 'tcmp_nonce' ) ) { | |
| 141 | - foreach ( $snippet as $k => $v ) { | |
| 142 | - $snippet[ $k ] = tcmp_qs( $k ); | |
| 143 | - if ( is_string( $snippet[ $k ] ) ) { | |
| 144 | - $snippet[ $k ] = stripslashes( $snippet[ $k ] ); | |
| 145 | - } | |
| 146 | - } | |
| 147 | - | |
| 148 | - tcmp_ui_editor_check( $snippet ); | |
| 149 | - if ( ! $tcmp->options->hasErrorMessages() ) { | |
| 150 | - $snippet = $tcmp->manager->put( $snippet['id'], $snippet ); | |
| 151 | - $id = $snippet['id']; | |
| 152 | - $tcmp->utils->redirect( TCMP_PAGE_MANAGER . '&id=' . $id ); } | |
| 153 | - } | |
| 154 | - $tcmp->options->writeMessages(); | |
| 155 | - | |
| 156 | - $tcmp->form->form_starts(); | |
| 157 | - $tcmp->form->hidden( 'id', $snippet ); | |
| 158 | - $tcmp->form->hidden( 'order', $snippet ); | |
| 159 | - | |
| 160 | - $tcmp->form->checkbox( 'active', $snippet ); | |
| 161 | - $tcmp->form->text( 'name', $snippet ); | |
| 162 | - $tcmp->form->editor( 'code', $snippet ); | |
| 163 | - | |
| 164 | - $values = array( TCMP_POSITION_HEAD, TCMP_POSITION_BODY, TCMP_POSITION_FOOTER ); | |
| 165 | - $tcmp->form->dropdown( 'position', $snippet, $values, false ); | |
| 166 | - $values = array( TCMP_DEVICE_TYPE_ALL, TCMP_DEVICE_TYPE_DESKTOP, TCMP_DEVICE_TYPE_MOBILE, TCMP_DEVICE_TYPE_TABLET ); | |
| 167 | - $tcmp->form->dropdown( 'deviceType', $snippet, $values, true ); | |
| 168 | - | |
| 169 | - $args = array( 'id' => 'box-track-mode' ); | |
| 170 | - $tcmp->form->div_starts( $args ); | |
| 171 | - { | |
| 172 | - $tcmp->form->p( 'Where do you want to add this code?' ); | |
| 173 | - $tcmp->form->radio( 'trackMode', $snippet['trackMode'], TCMP_TRACK_MODE_CODE ); | |
| 174 | - $plugins = $tcmp->ecommerce->getActivePlugins(); | |
| 175 | - if ( 0 === count( $plugins ) ) { | |
| 176 | - $plugins = array( | |
| 177 | - 'Ecommerce' => array( | |
| 178 | - 'name' => 'Ecommerce', | |
| 179 | - 'id' => TCMP_PLUGINS_NO_PLUGINS, | |
| 180 | - 'version' => '', | |
| 181 | - ), | |
| 182 | - ); | |
| 183 | - } | |
| 184 | - $tcmp->form->tag_new = true; | |
| 185 | - foreach ( $plugins as $k => $v ) { | |
| 186 | - $ecommerce = $v['name']; | |
| 187 | - if ( isset( $v['version'] ) && '' !== $v['version'] ) { | |
| 188 | - $ecommerce .= ' (v.' . $v['version'] . ')'; | |
| 189 | - } | |
| 190 | - $args = array( 'label' => $tcmp->lang->L( 'Editor.trackMode_1', $ecommerce ) ); | |
| 191 | - $tcmp->form->radio( 'trackMode', $snippet['trackMode'], $v['id'], $args ); | |
| 192 | - } | |
| 193 | - $tcmp->form->tag_new = false; | |
| 194 | - | |
| 195 | - } | |
| 196 | - $tcmp->form->div_ends(); | |
| 197 | - | |
| 198 | - $args = array( 'id' => 'box-track-conversion' ); | |
| 199 | - $tcmp->form->div_starts( $args ); | |
| 200 | - { | |
| 201 | - $tcmp->form->p( 'ConversionProductQuestion' ); | |
| 202 | - ?> | |
| 203 | - <p style="font-style: italic;"><?php $tcmp->lang->P( 'Editor.PositionBlocked' ); ?></p> | |
| 204 | - <?php | |
| 205 | - foreach ( $plugins as $k => $v ) { | |
| 206 | - $args = array( | |
| 207 | - 'id' => 'box-track-conversion-' . $v['id'], | |
| 208 | - 'class' => 'box-track-conversion', | |
| 209 | - ); | |
| 210 | - $tcmp->form->div_starts( $args ); | |
| 211 | - { | |
| 212 | - if ( TCMP_PLUGINS_NO_PLUGINS === $v['id'] ) { | |
| 213 | - $plugins = $tcmp->ecommerce->getPlugins( false ); | |
| 214 | - $ecommerce = ''; | |
| 215 | - foreach ( $plugins as $k => $v ) { | |
| 216 | - if ( '' !== $ecommerce ) { | |
| 217 | - $ecommerce .= ', '; | |
| 218 | - } | |
| 219 | - $ecommerce .= $k; | |
| 220 | - } | |
| 221 | - $tcmp->options->pushErrorMessage( 'Editor.NoEcommerceFound', $ecommerce ); | |
| 222 | - $tcmp->options->writeMessages(); | |
| 223 | - } else { | |
| 224 | - $post_type = $tcmp->ecommerce->getCustomPostType( $v['id'] ); | |
| 225 | - $key_active = 'CTC_' . $v['id'] . '_Active'; | |
| 226 | - $label = $tcmp->lang->L( 'Editor.EcommerceCheck', $v['name'], $v['version'] ); | |
| 227 | - | |
| 228 | - if ( '' != $post_type ) { | |
| 229 | - $args = array( | |
| 230 | - 'post_type' => $post_type, | |
| 231 | - 'all' => true, | |
| 232 | - ); | |
| 233 | - $values = $tcmp->utils->query( TCMP_QUERY_POSTS_OF_TYPE, $args ); | |
| 234 | - $key_array = 'CTC_' . $v['id'] . '_ProductsIds'; | |
| 235 | - if ( 0 === count( $snippet[ $key_array ] ) ) { | |
| 236 | - //when enabled default selected -1 | |
| 237 | - $snippet[ $key_array ] = array( -1 ); | |
| 238 | - } | |
| 239 | - | |
| 240 | - $args = array( | |
| 241 | - 'label' => $label, | |
| 242 | - 'class' => 'tcmp-select tcmLineTags', | |
| 243 | - ); | |
| 244 | - $tcmp->form->labels = false; | |
| 245 | - $tcmp->form->dropdown( $key_array, $snippet[ $key_array ], $values, true, $args ); | |
| 246 | - $tcmp->form->labels = true; | |
| 247 | - } else { | |
| 248 | - $args = array( 'label' => $label ); | |
| 249 | - $tcmp->form->checkbox( $key_active, $snippet[ $key_active ], 1, $args ); | |
| 250 | - } | |
| 251 | - } | |
| 252 | - } | |
| 253 | - $tcmp->form->div_ends(); | |
| 254 | - | |
| 255 | - $tcmp->form->br(); | |
| 256 | - $tcmp->form->i( 'ConversionDynamicFields' ); | |
| 257 | - $tcmp->form->br(); | |
| 258 | - $tcmp->form->br(); | |
| 259 | - } | |
| 260 | - } | |
| 261 | - $tcmp->form->div_ends(); | |
| 262 | - | |
| 263 | - $args = array( 'id' => 'box-track-code' ); | |
| 264 | - $tcmp->form->div_starts( $args ); | |
| 265 | - { | |
| 266 | - $tcmp->form->p( 'In which page do you want to insert this code?' ); | |
| 267 | - $tcmp->form->radio( 'trackPage', $snippet['trackPage'], TCMP_TRACK_PAGE_ALL ); | |
| 268 | - $tcmp->form->radio( 'trackPage', $snippet['trackPage'], TCMP_TRACK_PAGE_SPECIFIC ); | |
| 269 | - | |
| 270 | - //, 'style'=>'margin-top:10px;' | |
| 271 | - $args = array( 'id' => 'tcmp-include-div' ); | |
| 272 | - $tcmp->form->div_starts( $args ); | |
| 273 | - { | |
| 274 | - $tcmp->form->p( 'Include tracking code in which pages?' ); | |
| 275 | - tcmp_form_options( 'include', $snippet ); | |
| 276 | - } | |
| 277 | - $tcmp->form->div_ends(); | |
| 278 | - | |
| 279 | - $args = array( 'id' => 'tcmp-except-div' ); | |
| 280 | - $tcmp->form->div_starts( $args ); | |
| 281 | - { | |
| 282 | - $tcmp->form->p( 'Do you want to exclude some specific pages?' ); | |
| 283 | - tcmp_form_options( 'except', $snippet ); | |
| 284 | - } | |
| 285 | - $tcmp->form->div_ends(); | |
| 286 | - } | |
| 287 | - $tcmp->form->div_ends(); | |
| 288 | - | |
| 289 | - $tcmp->form->nonce( 'tcmp_nonce', 'tcmp_nonce' ); | |
| 290 | - tcmp_notice_pro_features(); | |
| 291 | - $tcmp->form->submit( 'Save' ); | |
| 292 | - $tcmp->form->form_ends(); | |
| 293 | -} | |
| 294 | - | |
| 295 | -function tcmp_form_options( $prefix, $snippet ) { | |
| 296 | - global $tcmp; | |
| 297 | - | |
| 298 | - $types = $tcmp->utils->query( TCMP_QUERY_POST_TYPES ); | |
| 299 | - foreach ( $types as $v ) { | |
| 300 | - $args = array( | |
| 301 | - 'post_type' => $v['id'], | |
| 302 | - 'all' => true, | |
| 303 | - ); | |
| 304 | - $values = $tcmp->utils->query( TCMP_QUERY_POSTS_OF_TYPE, $args ); | |
| 305 | - //$tcmp->form->premium=!in_array($v['name'], array('post', 'page')); | |
| 306 | - | |
| 307 | - $key_active = $prefix . 'PostsOfType_' . $v['id'] . '_Active'; | |
| 308 | - $key_array = $prefix . 'PostsOfType_' . $v['id']; | |
| 309 | - if ( 0 === $snippet[ $key_active ] && 0 === count( $snippet[ $key_array ] ) && 'except' != $prefix ) { | |
| 310 | - //when enabled default selected -1 | |
| 311 | - $snippet[ $key_array ] = array( -1 ); | |
| 312 | - } | |
| 313 | - $tcmp->form->check_select( $key_active, $key_array, $snippet, $values ); | |
| 314 | - } | |
| 315 | -} | |
| 1 | +<?php | |
| 2 | +function tcm_ui_editor() { | |
| 3 | + global $tcm; | |
| 4 | + | |
| 5 | + $tcm->Form->prefix = 'Editor'; | |
| 6 | + $id = intval($tcm->Utils->qs('id', 0)); | |
| 7 | + $action = $tcm->Utils->qs('action'); | |
| 8 | + $snippet = $tcm->Manager->get($id, TRUE); | |
| 9 | + //var_dump($snippet); | |
| 10 | + | |
| 11 | + if (wp_verify_nonce($tcm->Utils->qs('tcm_nonce'), 'tcm_nonce')) { | |
| 12 | + //var_dump($_POST); | |
| 13 | + //var_dump($_GET); | |
| 14 | + foreach ($snippet as $k => $v) { | |
| 15 | + $snippet[$k] = $tcm->Utils->qs($k); | |
| 16 | + if (is_string($snippet[$k])) { | |
| 17 | + $snippet[$k] = stripslashes($snippet[$k]); | |
| 18 | + } | |
| 19 | + } | |
| 20 | + | |
| 21 | + if ($snippet['name'] == '') { | |
| 22 | + $tcm->Options->pushErrorMessage('Please enter a unique name'); | |
| 23 | + } else { | |
| 24 | + $exist=$tcm->Manager->exists($snippet['name']); | |
| 25 | + if ($exist && $exist['id'] != $snippet['id']) { | |
| 26 | + //nonostante il tutto il nome deve essee univoco | |
| 27 | + $tcm->Options->pushErrorMessage('You have entered a name that already exists. IDs are NOT case-sensitive'); | |
| 28 | + } | |
| 29 | + } | |
| 30 | + if ($snippet['code'] == '') { | |
| 31 | + $tcm->Options->pushErrorMessage('Paste your HTML Tracking Code into the textarea'); | |
| 32 | + } | |
| 33 | + | |
| 34 | + if (!$tcm->Options->hasErrorMessages()) { | |
| 35 | + $snippet = $tcm->Manager->put($snippet['id'], $snippet); | |
| 36 | + if ($id <= 0) { | |
| 37 | + $tcm->Options->pushSuccessMessage('Editor.Add', $snippet['id'], $snippet['name']); | |
| 38 | + $snippet = $tcm->Manager->get('', TRUE); | |
| 39 | + } else { | |
| 40 | + $tcm->Utils->redirect(TCM_PAGE_MANAGER.'&id='.$id); | |
| 41 | + exit(); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + } | |
| 45 | + $tcm->Options->writeMessages(); | |
| 46 | + | |
| 47 | + if($tcm->Manager->rc()<=0 && $id<=0) { | |
| 48 | + $tcm->Utils->redirect(TCM_PAGE_MANAGER); | |
| 49 | + exit(); | |
| 50 | + } | |
| 51 | + tcm_ui_free_notice(); | |
| 52 | + | |
| 53 | + ?> | |
| 54 | + <script> | |
| 55 | + jQuery(function(){ | |
| 56 | + var tcmPostTypes=[]; | |
| 57 | + | |
| 58 | + <?php | |
| 59 | + $types=$tcm->Utils->query(TCM_QUERY_POST_TYPES); | |
| 60 | + foreach($types as $v) { ?> | |
| 61 | + tcmPostTypes.push('<?php echo $v['name']?>'); | |
| 62 | + <?php } ?> | |
| 63 | + | |
| 64 | + //enable/disable some part of except creating coherence | |
| 65 | + function tcmCheckVisible() { | |
| 66 | + var showExceptCategories=true; | |
| 67 | + var showExceptTags=true; | |
| 68 | + var showExceptPostTypes={}; | |
| 69 | + jQuery.each(tcmPostTypes, function (i,v) { | |
| 70 | + showExceptPostTypes[v]=true; | |
| 71 | + }); | |
| 72 | + | |
| 73 | + var $all=jQuery('#includeEverywhereActive'); | |
| 74 | + if(!$all.is(':checked')) { | |
| 75 | + showExceptCategories=false; | |
| 76 | + showExceptTags=false; | |
| 77 | + | |
| 78 | + jQuery.each(tcmPostTypes, function (i,v) { | |
| 79 | + isCheck=jQuery('#includePostsOfType_'+v+'_Active').is(':checked'); | |
| 80 | + selection=jQuery('#includePostsOfType_'+v).select2("val"); | |
| 81 | + found=false; | |
| 82 | + for(i=0; i<selection.length; i++) { | |
| 83 | + if(parseInt(selection[i])==-1){ | |
| 84 | + found=true; | |
| 85 | + } | |
| 86 | + } | |
| 87 | + | |
| 88 | + showExceptPostTypes[v]=false; | |
| 89 | + if(isCheck && found) { | |
| 90 | + showExceptPostTypes[v]=true; | |
| 91 | + if(v!='page') { | |
| 92 | + showExceptCategories=true; | |
| 93 | + showExceptTags=true; | |
| 94 | + } | |
| 95 | + } | |
| 96 | + }); | |
| 97 | + } | |
| 98 | + | |
| 99 | + //hide/show except post type if all the website is selected | |
| 100 | + //or [All] is selected in a specific post type select | |
| 101 | + var showExcept=false; | |
| 102 | + jQuery.each(showExceptPostTypes, function (k,v) { | |
| 103 | + if(v) { | |
| 104 | + //at least one post type to show except | |
| 105 | + showExcept=true; | |
| 106 | + } | |
| 107 | + tcmShowHide('#exceptPostsOfType_'+k+'Box', v); | |
| 108 | + }); | |
| 109 | + | |
| 110 | + tcmShowHide('#exceptCategoriesBox', showExceptCategories); | |
| 111 | + tcmShowHide('#exceptTagsBox', showExceptTags); | |
| 112 | + | |
| 113 | + showExcept=(showExcept || showExceptTags || showExceptCategories); | |
| 114 | + tcmShowHide('#tcm-except-div', showExcept); | |
| 115 | + } | |
| 116 | + function tcmShowHide(selector, show) { | |
| 117 | + $selector=jQuery(selector); | |
| 118 | + if(show) { | |
| 119 | + $selector.show(); | |
| 120 | + } else { | |
| 121 | + $selector.hide(); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + /*jQuery(".tcmTags").select2({ | |
| 126 | + placeholder: "Type here..." | |
| 127 | + , theme: "classic" | |
| 128 | + }).on('change', function() { | |
| 129 | + tcmCheckVisible(); | |
| 130 | + });*/ | |
| 131 | + jQuery(".tcmLineTags").select2({ | |
| 132 | + placeholder: "Type here..." | |
| 133 | + , theme: "classic" | |
| 134 | + , width: '550px' | |
| 135 | + }); | |
| 136 | + | |
| 137 | + jQuery('.tcm-hideShow').click(function() { | |
| 138 | + tcmCheckVisible(); | |
| 139 | + }); | |
| 140 | + jQuery('.tcm-hideShow, input[type=checkbox]').change(function() { | |
| 141 | + tcmCheckVisible(); | |
| 142 | + }); | |
| 143 | + jQuery('.tcmLineTags').on('change', function() { | |
| 144 | + tcmCheckVisible(); | |
| 145 | + }); | |
| 146 | + tcmCheckVisible(); | |
| 147 | + }); | |
| 148 | + </script> | |
| 149 | + <?php | |
| 150 | + | |
| 151 | + $tcm->Form->formStarts(); | |
| 152 | + $tcm->Form->hidden('id', $snippet); | |
| 153 | + $tcm->Form->checkbox('active', $snippet); | |
| 154 | + $tcm->Form->text('name', $snippet); | |
| 155 | + $tcm->Form->textarea('code', $snippet); | |
| 156 | + $values = array(TCM_POSITION_HEAD, TCM_POSITION_BODY, TCM_POSITION_FOOTER); | |
| 157 | + $tcm->Form->select('position', $snippet, $values, FALSE); | |
| 158 | + | |
| 159 | + $tcm->Form->p('When do you want to add this code?'); | |
| 160 | + $args=array('class'=>'tcm-hideShow tcm-checkbox' | |
| 161 | + , 'tcm-hideIfTrue'=>'true' | |
| 162 | + , 'tcm-hideShow'=>'tcm-include-div'); | |
| 163 | + $tcm->Form->checkbox('includeEverywhereActive', $snippet, 1, $args); | |
| 164 | + | |
| 165 | + $args=array('id'=>'tcm-include-div', 'name'=>'tcm-include-div', 'style'=>'margin-top:10px;'); | |
| 166 | + $tcm->Form->divStarts($args); | |
| 167 | + tcm_formOptions('include', $snippet); | |
| 168 | + $tcm->Form->divEnds(); | |
| 169 | + | |
| 170 | + $args=array('id'=>'tcm-except-div', 'name'=>'tcm-except-div'); | |
| 171 | + $tcm->Form->divStarts($args); | |
| 172 | + $tcm->Form->p('Exclude when?'); | |
| 173 | + tcm_formOptions('except', $snippet); | |
| 174 | + $tcm->Form->divEnds(); | |
| 175 | + | |
| 176 | + $tcm->Form->nonce('tcm_nonce', 'tcm_nonce'); | |
| 177 | + tcm_notice_pro_features(); | |
| 178 | + $tcm->Form->submit('Save'); | |
| 179 | + if($id>0) { | |
| 180 | + $tcm->Form->delete($id); | |
| 181 | + } | |
| 182 | + $tcm->Form->formEnds(); | |
| 183 | +} | |
| 184 | + | |
| 185 | +function tcm_notice_pro_features() { | |
| 186 | + global $tcm; | |
| 187 | + | |
| 188 | + ?> | |
| 189 | + <br/> | |
| 190 | + <div class="message updated below-h2"> | |
| 191 | + <div style="height:10px;"></div> | |
| 192 | + <?php | |
| 193 | + $i=1; | |
| 194 | + while($tcm->Lang->H('Notice.ProHeader'.$i)) { | |
| 195 | + $tcm->Lang->P('Notice.ProHeader'.$i); | |
| 196 | + echo '<br/>'; | |
| 197 | + ++$i; | |
| 198 | + } | |
| 199 | + $i=1; | |
| 200 | + ?> | |
| 201 | + <br/> | |
| 202 | + <?php | |
| 203 | + | |
| 204 | + $options = array('public' => TRUE, '_builtin' => FALSE); | |
| 205 | + $q=get_post_types($options, 'names'); | |
| 206 | + if(is_array($q) && count($q)>0) { | |
| 207 | + sort($q); | |
| 208 | + $q=implode(', ', $q); | |
| 209 | + $q='(<b>'.$q.'</b>)'; | |
| 210 | + } else { | |
| 211 | + $q=''; | |
| 212 | + } | |
| 213 | + | |
| 214 | + while($tcm->Lang->H('Notice.ProFeature'.$i)) { ?> | |
| 215 | + <div style="clear:both; margin-top: 2px;"></div> | |
| 216 | + <div style="float:left; vertical-align:middle; height:24px; margin-right:5px;"> | |
| 217 | + <img src="<?php echo TCM_PLUGIN_IMAGES?>tick.png" /> | |
| 218 | + </div> | |
| 219 | + <div style="float:left; vertical-align:middle; height:24px;"> | |
| 220 | + <?php $tcm->Lang->P('Notice.ProFeature'.$i, $q)?> | |
| 221 | + </div> | |
| 222 | + <?php ++$i; | |
| 223 | + } | |
| 224 | + ?> | |
| 225 | + <div style="clear:both;"></div> | |
| 226 | + <div style="height:10px;"></div> | |
| 227 | + </div> | |
| 228 | + <br/> | |
| 229 | +<?php } | |
| 230 | + | |
| 231 | +function tcm_formOptions($prefix, $snippet) { | |
| 232 | + global $tcm; | |
| 233 | + | |
| 234 | + $types=$tcm->Utils->query(TCM_QUERY_POST_TYPES); | |
| 235 | + foreach($types as $v) { | |
| 236 | + $args = array('post_type' => $v['name'], 'all' => TRUE); | |
| 237 | + $values = $tcm->Utils->query(TCM_QUERY_POSTS_OF_TYPE, $args); | |
| 238 | + | |
| 239 | + $keyActive=$prefix.'PostsOfType_'.$v['name'].'_Active'; | |
| 240 | + $keyArray=$prefix.'PostsOfType_'.$v['name']; | |
| 241 | + if($snippet[$keyActive]==0 && count($snippet[$keyArray])==0) { | |
| 242 | + //when enabled default selected -1 | |
| 243 | + $snippet[$keyArray]=array(-1); | |
| 244 | + } | |
| 245 | + $tcm->Form->checkSelect($keyActive, $keyArray, $snippet, $values); | |
| 246 | + } | |
| 247 | +} | |