admin-content.php
6 years ago
folder-deactivate-form.php
6 years ago
general-settings.php
6 years ago
help.php
6 years ago
update.php
6 years ago
upgrade-to-pro.php
6 years ago
general-settings.php
168 lines
| 1 | <?php |
| 2 | defined('ABSPATH') or wp_die('Nope, not accessing this'); |
| 3 | ?> |
| 4 | <style> |
| 5 | span.upgrade-message { |
| 6 | padding: 5px 10px; |
| 7 | background: #fff; |
| 8 | display: inline-block; |
| 9 | font-size: 14px; |
| 10 | color: #000; |
| 11 | } |
| 12 | a.pink, span.pink { |
| 13 | color: #FF5983; |
| 14 | text-decoration: none; |
| 15 | font-weight: bold; |
| 16 | } |
| 17 | #setting-form { |
| 18 | float: left; |
| 19 | width: 580px; |
| 20 | } |
| 21 | .form-table th.default-folder { |
| 22 | width: 100px; |
| 23 | } |
| 24 | .premio-help { |
| 25 | width: calc(100% - 600px); |
| 26 | float: left; |
| 27 | text-align: center; |
| 28 | } |
| 29 | .premio-help a { |
| 30 | display: inline-block; |
| 31 | width: 200px; |
| 32 | margin-top: 15px; |
| 33 | } |
| 34 | .premio-help a img { |
| 35 | width: 100%; |
| 36 | height: auto; |
| 37 | } |
| 38 | .hide-option { |
| 39 | display: none; |
| 40 | } |
| 41 | select.hide-show-option { |
| 42 | width: 170px; |
| 43 | } |
| 44 | <?php if ( function_exists( 'is_rtl' ) && is_rtl() ) { ?> |
| 45 | #setting-form { |
| 46 | float: right; |
| 47 | } |
| 48 | <?php } ?> |
| 49 | </style> |
| 50 | <script> |
| 51 | jQuery(document).ready(function(){ |
| 52 | jQuery(document).on("click",".folder-select",function(){ |
| 53 | if(jQuery(this).is(":checked")) { |
| 54 | jQuery(this).closest("tr").find(".hide-show-option").removeClass("hide-option"); |
| 55 | } else { |
| 56 | jQuery(this).closest("tr").find(".hide-show-option").addClass("hide-option"); |
| 57 | } |
| 58 | }); |
| 59 | }); |
| 60 | </script> |
| 61 | <div class="wrap"> |
| 62 | <h1><?php esc_attr_e( 'Folders Settings', WCP_FOLDER ); ?></h1> |
| 63 | <form action="options.php" method="post" id="setting-form"> |
| 64 | <?php |
| 65 | settings_fields('folders_settings'); |
| 66 | settings_fields('default_folders'); |
| 67 | $options = get_option('folders_settings'); |
| 68 | $default_folders = get_option('default_folders'); |
| 69 | $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders; |
| 70 | do_settings_sections( __FILE__ ); |
| 71 | ?> |
| 72 | <table class="form-table"> |
| 73 | <?php |
| 74 | $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
| 75 | $post_array = array("page", "post", "attachment"); |
| 76 | foreach ( $post_types as $post_type ) : ?> |
| 77 | <?php |
| 78 | if ( ! $post_type->show_ui) continue; |
| 79 | $is_checked = !in_array( $post_type->name, $options )?"hide-option":""; |
| 80 | $selected_id = (isset($default_folders[$post_type->name]))?$default_folders[$post_type->name]:"all"; |
| 81 | if(in_array($post_type->name, $post_array)){ |
| 82 | ?> |
| 83 | <tr> |
| 84 | <th> |
| 85 | <label for="folders_<?php echo esc_attr($post_type->name); ?>" ><?php esc_html_e( 'Use folders with: ', WCP_FOLDER )." ".esc_html_e($post_type->label); ?></label> |
| 86 | </th> |
| 87 | <td> |
| 88 | <input type="checkbox" class="folder-select" id="folders_<?php echo esc_attr($post_type->name); ?>" name="folders_settings[]" value="<?php echo esc_attr($post_type->name); ?>"<?php if ( in_array( $post_type->name, $options ) ) echo ' checked="checked"'; ?>/> |
| 89 | </td> |
| 90 | <th class="default-folder"> |
| 91 | <label class="hide-show-option <?php echo esc_attr($is_checked) ?>" for="folders_for_<?php echo esc_attr($post_type->name); ?>" ><?php esc_html_e( 'Default folder: ', WCP_FOLDER ) ?></label> |
| 92 | </th> |
| 93 | <td> |
| 94 | <select class="hide-show-option <?php echo esc_attr($is_checked) ?>" id="folders_for_<?php echo esc_attr($post_type->name); ?>" name="default_folders[<?php echo esc_attr($post_type->name); ?>]" ?>"> |
| 95 | <option value="">All <?php echo esc_attr($post_type->label) ?> Folders</option> |
| 96 | <option value="-1" <?php echo ($selected_id == -1)?"selected":"" ?>>Unassigned <?php echo esc_attr($post_type->label) ?></option> |
| 97 | <?php |
| 98 | if(isset($terms_data[$post_type->name]) && !empty($terms_data[$post_type->name])) { |
| 99 | foreach ($terms_data[$post_type->name] as $term) { |
| 100 | $selected = ($selected_id == $term->slug)?"selected":""; |
| 101 | echo "<option ".esc_attr($selected)." value='".esc_attr($term->slug)."'>".esc_attr($term->name)."</option>"; |
| 102 | } |
| 103 | } ?> |
| 104 | </select> |
| 105 | </td> |
| 106 | </tr> |
| 107 | <?php |
| 108 | } else { ?> |
| 109 | <tr> |
| 110 | <th> |
| 111 | <label for="folders_<?php echo esc_attr($post_type->name); ?>" ><?php esc_html_e( 'Use folders with: ', WCP_FOLDER )." ".esc_html_e($post_type->label); ?></label> |
| 112 | </th> |
| 113 | <td> |
| 114 | <input type="checkbox" class="folder-select" id="folders_<?php echo esc_attr($post_type->name); ?>" name="folders_settings[]" value="<?php echo esc_attr($post_type->name); ?>"<?php if ( in_array( $post_type->name, $options ) ) echo ' checked="checked"'; ?>/> |
| 115 | </td> |
| 116 | <th class="default-folder"> |
| 117 | <label class="hide-show-option <?php echo esc_attr($is_checked) ?>" for="folders_for_<?php echo esc_attr($post_type->name); ?>" ><?php esc_html_e( 'Default folder: ', WCP_FOLDER ) ?></label> |
| 118 | </th> |
| 119 | <td> |
| 120 | <select class="hide-show-option <?php echo esc_attr($is_checked) ?>" id="folders_for_<?php echo esc_attr($post_type->name); ?>" name="default_folders[<?php echo esc_attr($post_type->name); ?>]" ?>"> |
| 121 | <option value="">All <?php echo esc_attr($post_type->label) ?> Folders</option> |
| 122 | <option value="-1" <?php echo ($selected_id == -1)?"selected":"" ?>>Unassigned <?php echo esc_attr($post_type->label) ?></option> |
| 123 | <?php |
| 124 | if(isset($terms_data[$post_type->name]) && !empty($terms_data[$post_type->name])) { |
| 125 | foreach ($terms_data[$post_type->name] as $term) { |
| 126 | $selected = ($selected_id == $term->slug)?"selected":""; |
| 127 | echo "<option ".esc_attr($selected)." value='".esc_attr($term->slug)."'>".esc_attr($term->name)."</option>"; |
| 128 | } |
| 129 | } ?> |
| 130 | </select> |
| 131 | </td> |
| 132 | </tr> |
| 133 | <?php } endforeach; ?> |
| 134 | <tr> |
| 135 | <th> |
| 136 | <label for="folders_<?php echo esc_attr($post_type->name); ?>" ><?php esc_html_e( 'Show Folders in Menu:', WCP_FOLDER ); ?></label> |
| 137 | </th> |
| 138 | <td> |
| 139 | <?php $val = get_option("folders_show_in_menu"); ?> |
| 140 | <input type="hidden" name="folders_show_in_menu" value="off" /> |
| 141 | <input type="checkbox" name="folders_show_in_menu" value="on" <?php echo ($val == "on")?"checked='checked'":"" ?>/> |
| 142 | </td> |
| 143 | </tr> |
| 144 | <tr> |
| 145 | <td colspan="2" style="padding: 10px 0"> |
| 146 | <?php |
| 147 | $total_folders = get_option("folder_old_plugin_folder_status"); |
| 148 | if($total_folders == false || $total_folders < 10) { |
| 149 | $total_folders = 10; |
| 150 | } |
| 151 | $total = WCP_Folders::get_total_term_folders(); |
| 152 | if($total > $total_folders) { |
| 153 | $total_folders = $total; |
| 154 | } |
| 155 | ?> |
| 156 | <span class="upgrade-message">You have used <span class='pink'><?php echo esc_attr($total) ?></span>/<?php echo esc_attr($total_folders) ?> Folders. <a class="pink" href="<?php echo esc_url(admin_url("admin.php?page=wcp_folders_upgrade")) ?>"><?php esc_html_e("Upgrade", WCP_FOLDER) ?></a></span> |
| 157 | </td> |
| 158 | </tr> |
| 159 | </table> |
| 160 | <input type="hidden" name="folders_settings1[premio_folder_option]" value="yes" /> |
| 161 | <?php submit_button(); ?> |
| 162 | </form> |
| 163 | <div class="premio-help"> |
| 164 | <a href="https://premio.io/help/folders/?utm_source=pluginspage" target="_blank"> |
| 165 | <img src="<?php echo esc_url(WCP_FOLDER_URL."assets/images/premio-help.png") ?>" alt="Premio Help" class="Premio Help" /> |
| 166 | </a> |
| 167 | </div> |
| 168 | </div> |