AdminOptions.php
3 years ago
editor.php
3 years ago
manager.php
2 years ago
metabox.php
3 years ago
settings.php
3 years ago
whatsnew.php
3 years ago
manager.php
117 lines
| 1 | <?php |
| 2 | |
| 3 | function tcmp_ui_manager() { |
| 4 | global $tcmp; |
| 5 | |
| 6 | $id = tcmp_isqs( 'id', 0 ); |
| 7 | if ( tcmp_sqs( 'action' ) === 'delete' && $id > 0 && wp_verify_nonce( tcmp_qs( 'tcmp_nonce' ), 'tcmp_delete' ) ) { |
| 8 | $snippet = $tcmp->manager->get( $id ); |
| 9 | if ( $tcmp->manager->remove( $id ) ) { |
| 10 | $tcmp->options->pushSuccessMessage( 'CodeDeleteNotice', $id, esc_html( $snippet['name'] ) ); |
| 11 | } |
| 12 | } elseif ( '' != $id && 0 != $id ) { |
| 13 | $snippet = $tcmp->manager->get( $id ); |
| 14 | if ( $tcmp->utils->is( 'action', 'toggle' ) && $id > 0 && wp_verify_nonce( tcmp_qs( 'tcmp_nonce' ), 'tcmp_toggle' ) ) { |
| 15 | $snippet['active'] = ( 0 === $snippet['active'] ? 1 : 0 ); |
| 16 | $tcmp->manager->put( $snippet['id'], $snippet ); |
| 17 | } |
| 18 | $tcmp->options->pushSuccessMessage( 'CodeUpdateNotice', $id, esc_html( $snippet['name'] ) ); |
| 19 | } |
| 20 | |
| 21 | $tcmp->manager->is_limit_reached( true ); |
| 22 | $tcmp->options->writeMessages(); |
| 23 | |
| 24 | //controllo che faccio per essere retrocompatibile con la prima versione |
| 25 | //dove non avevo un id e salvavo tutto con il con il nome quindi una stringa |
| 26 | $snippets = $tcmp->manager->keys(); |
| 27 | foreach ( $snippets as $v ) { |
| 28 | $snippet = $tcmp->manager->get( $v, false, true ); |
| 29 | if ( ! $snippet ) { |
| 30 | $tcmp->manager->remove( $v ); |
| 31 | } elseif ( ! is_numeric( $v ) ) { |
| 32 | $tcmp->manager->remove( $v ); |
| 33 | $tcmp->manager->put( '', $snippet ); |
| 34 | } |
| 35 | } |
| 36 | $snippets = $tcmp->manager->values(); |
| 37 | if ( count( $snippets ) > 0 ) { ?> |
| 38 | <div style="float:left;"> |
| 39 | <form method="get" action="" style="margin:5px; float:left;"> |
| 40 | <input type="hidden" name="page" value="<?php echo TCMP_PLUGIN_SLUG; ?>" /> |
| 41 | <input type="hidden" name="tab" value="<?php echo TCMP_TAB_EDITOR; ?>" /> |
| 42 | <input type="submit" class="button-primary" value="<?php $tcmp->lang->P( 'Button.Add' ); ?>" /> |
| 43 | </form> |
| 44 | </div> |
| 45 | <div style="clear:both;"></div> |
| 46 | |
| 47 | <table class="widefat fixed" style="width:100%" id="tblSortable"> |
| 48 | <thead> |
| 49 | <tr> |
| 50 | <th style="width:30px;">#N</th> |
| 51 | <th style="width:50px; text-align:center;"><?php $tcmp->lang->P( 'Active?' ); ?></th> |
| 52 | <th><?php $tcmp->lang->P( 'Name' ); ?></th> |
| 53 | <th><?php $tcmp->lang->P( 'Where?' ); ?></th> |
| 54 | <th style="text-align:center;"><?php $tcmp->lang->P( 'Shortcode' ); ?></th> |
| 55 | <th style="text-align:center;"><?php $tcmp->lang->P( 'Actions' ); ?></th> |
| 56 | </tr> |
| 57 | </thead> |
| 58 | <tbody class="table-body"> |
| 59 | <?php |
| 60 | $i = 1; |
| 61 | foreach ( $snippets as $snippet ) { |
| 62 | global $tcmp_allowed_html_tags; |
| 63 | $bClass = ( ( $i % 2 ) === 1 ? 'odd' : 'even' ); |
| 64 | ?> |
| 65 | <tr class="<?php echo esc_attr( $bClass ); ?>" id="row_<?php echo esc_attr( $snippet['id'] ); ?>"> |
| 66 | <td>#<?php echo esc_html( $i++ ); ?></td> |
| 67 | <td style="text-align:center;"> |
| 68 | <?php |
| 69 | $color = 'red'; |
| 70 | $text = 'No'; |
| 71 | $question = 'QuestionActiveOn'; |
| 72 | if ( 1 == $snippet['active'] ) { |
| 73 | $color = 'green'; |
| 74 | $text = 'Yes'; |
| 75 | $question = 'QuestionActiveOff'; |
| 76 | } |
| 77 | $text = '<span style="font-weight:bold; color:' . $color . '">' . $tcmp->lang->L( $text ) . '</span>'; |
| 78 | ?> |
| 79 | <a onclick="return confirm('<?php echo esc_attr( $tcmp->lang->L( $question ) ); ?>');" href="<?php echo TCMP_TAB_MANAGER_URI; ?>&tcmp_nonce=<?php echo esc_attr( wp_create_nonce( 'tcmp_toggle' ) ); ?>&action=toggle&id=<?php echo esc_attr( $snippet['id'] ); ?>"> |
| 80 | <?php echo wp_kses( $text, $tcmp_allowed_html_tags ); ?> |
| 81 | </a> |
| 82 | </td> |
| 83 | <td><?php echo esc_html( $snippet['name'] ); ?></td> |
| 84 | <td> |
| 85 | <?php |
| 86 | if ( $tcmp->manager->is_mode_script( $snippet ) ) { |
| 87 | if ( $tcmp->manager->is_page_everywhere( $snippet ) ) { |
| 88 | $text = 'Everywhere'; |
| 89 | } else { |
| 90 | $text = 'Specific Pages'; |
| 91 | } |
| 92 | } else { |
| 93 | $text = 'Conversion'; |
| 94 | } |
| 95 | esc_html( $tcmp->lang->P( $text ) ); |
| 96 | ?> |
| 97 | </td> |
| 98 | <td style="text-align:center;"> |
| 99 | <input type="text" style="width:110px; text-align:center;" value='[tcm id="<?php echo esc_html( $snippet['id'] ); ?>"]' readonly="readonly" class="tcmp-select-onfocus" /> |
| 100 | </td> |
| 101 | <td style="text-align:center;"> |
| 102 | <input type="button" class="button button-secondary" value="<?php $tcmp->lang->P( 'Edit' ); ?>" onclick="location.href='<?php echo TCMP_TAB_EDITOR_URI; ?>&id=<?php echo esc_attr( $snippet['id'] ); ?>';"/> |
| 103 | <input type="button" class="button button-secondary" value="<?php $tcmp->lang->P( 'Delete?' ); ?>" onclick="TCMP_btnDeleteClick(<?php echo esc_attr( $snippet['id'] ); ?>)"/> |
| 104 | </td> |
| 105 | </tr> |
| 106 | <?php } ?> |
| 107 | </tbody> |
| 108 | </table> |
| 109 | <?php |
| 110 | tcmp_notice_pro_features(); |
| 111 | } else { |
| 112 | ?> |
| 113 | <h2><?php $tcmp->lang->P( 'EmptyTrackingList', TCMP_TAB_EDITOR_URI ); ?></h2> |
| 114 | <?php |
| 115 | } |
| 116 | } |
| 117 |