bp_cover_settings

The BuddyPress cover bp cover settings function.

Description

bp_cover_settings(); 

Usage

  1. if ( !function_exists( 'bp_cover_settings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-cover/bp-cover-admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_cover_settings(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-cover-admin.php  
  1. function bp_cover_settings() {  
  2. if(isset($_POST['bp_cover_submit'])) { 
  3. update_option( "bp_cover_avatar", $_POST['bp_cover_avatar'] ); 
  4. update_option( "bp_cover_profile", $_POST['bp_cover_profile'] ); 
  5. update_option( "bp_cover_group", $_POST['bp_cover_group'] ); 
  6. update_option( "bp_cover_profie_item", $_POST['bp_cover_profie_item'] ); 
  7. update_option( "bp_cover_max_upload_size", $_POST['bp_cover_max_upload_size'] );  
  8.  
  9.  
  10. }if(isset($_POST['bp_cover_submit_skin'])) { 
  11. update_option( "bp_cover_skin", $_POST['bp_cover_skin'] ); 
  12.  
  13. $cover_profile = get_option( 'bp_cover_profile' ); 
  14. $cover_group = get_option( 'bp_cover_group' ); 
  15. $bp_cover_avatar = get_option( 'bp_cover_avatar' ); 
  16.  
  17. ?> 
  18. <div class="wrap"> 
  19. <h2></h2> 
  20. <div class="htcover"> 
  21. <form method="post" action="https://www.okpay.com/process.html"><input type="hidden" name="ok_receiver" value="OK618585115"/> 
  22. <input type="hidden" name="ok_item_1_name" value="bp-cover"/> 
  23. <input type="hidden" name="ok_currency" value="EUR"/> 
  24. <input type="hidden" name="ok_item_1_type" value="donation"/> 
  25. <input type="image" name="submit" alt="OKPAY Payment" src="https://www.okpay.com/img/buttons/en/donate/d14b186x54en.png"/></form>  
  26. <h1> <?php _e('Settings', 'bp-cover'); ?></h1>  
  27. </div> 
  28. <div class="tabs"> 
  29. <a href="#" data-tab="1" class="tab active"><?php _e('Bp cover', 'bp-cover'); ?></a> 
  30. <a href="#" data-tab="2" class="tab "><?php _e('Skins', 'bp-cover'); ?></a> 
  31. <a href="#" data-tab="3" class="tab"><?php _e('Other plugins', 'bp-cover'); ?></a> 
  32. <div data-content="1" class="content active"> 
  33. <form action="" method="post"> 
  34. <table width="100%" border="0" cellspacing="5" cellpadding="5">  
  35. <tr class="cover-group"> 
  36. <td class="row"><?php _e('Max total cover', 'bp-cover');?></td> 
  37. <td><input type="text" name="bp_cover_profie_item" value="<?php print get_option('bp_cover_profie_item'); ?>"></input></td>  
  38. <td> 
  39. <p style="font-size:10px; color:#ccc;" ><?php _e('Max total images allowed in a cover gallery', 'bp-cover');?></p> 
  40. <p style="font-size:10px; color:#ccc;" ><?php _e('If empty field user can upload only 20 total images', 'bp-cover');?></p> 
  41. </td> 
  42. </tr> 
  43. <tr class="cover-group"> 
  44. <td class="row"><?php _e('Max upload file size', 'bp-cover');?></td> 
  45. <td><input type="text" name="bp_cover_max_upload_size" value="<?php print get_option('bp_cover_max_upload_size'); ?>"size="10">kb</input></td>  
  46. <td> 
  47. <p style="font-size:10px; color:#ccc;" ><?php _e('Maximum file size (kb) that can be uploaded', 'bp-cover');?></p> 
  48. <p style="font-size:10px; color:#ccc;" ><?php _e('If empty maximum file size 2M that can be uploaded', 'bp-cover');?></p> 
  49. </td>  
  50. </tr> 
  51. <tr class="cover-avatar"> 
  52. <td><?php _e('Default avatar', 'bp-cover');?></td> 
  53. <td> 
  54. <span class='upload'> 
  55. <input type='text' id='bp_cover_avatar' class='regular-text text-upload' name='bp_cover_avatar' value='<?php print esc_url( $bp_cover_avatar ); ?>'/> 
  56. <input type='button' class='button button-upload button-primary' value='<?php _e('Upload an image', 'bp-cover');?>'/> 
  57. <a href="#" class="remove-btn button" ><?php _e('Delete', 'bp-cover');?></a><?php 
  58. if(!empty($bp_cover_avatar)):  
  59. ?> 
  60. <td><img src='<?php print esc_url( $bp_cover_avatar ); ?>' class='preview-upload' /></td>  
  61. <?php else :?> 
  62. <td><p style="font-size:10px; color:#ccc;" ><?php _e('Please upload an image', 'bp-cover');?></p> </td> 
  63. <?php endif ?> 
  64.  
  65. </span>  
  66. </td>  
  67. </tr> 
  68. <tr class="cover"> 
  69. <td><?php _e('Default cover profile', 'bp-cover');?></td> 
  70. <td> 
  71. <span class='upload'> 
  72. <input type='text' id='cover_profile' class='regular-text text-upload' name='bp_cover_profile' value='<?php print esc_url( $cover_profile ); ?>'/> 
  73. <input type='button' class='button button-upload button-primary' value='<?php _e('Upload an image', 'bp-cover');?>'/> 
  74. <a href="#" class="remove-btn button" ><?php _e('Delete', 'bp-cover');?></a><?php 
  75. if(!empty($cover_profile)):  
  76. ?> 
  77. <td><img src='<?php print esc_url( $cover_profile ); ?>' class='preview-upload' /></td>  
  78. <?php else :?> 
  79. <td><p style="font-size:10px; color:#ccc;" ><?php _e('Please upload an image', 'bp-cover');?></p> </td> 
  80. <?php endif ?> 
  81. </span>  
  82. </td>  
  83. </tr>  
  84. <tr class="cover-group"> 
  85. <td><?php _e('Default cover group', 'bp-cover');?></td> 
  86. <td> 
  87. <span class='upload'> 
  88. <input type='text' id='cover_group' class='regular-text text-upload' name='bp_cover_group' value='<?php print esc_url( $cover_group ); ?>'/> 
  89. <input type='button' class='button button-upload button-primary' value='<?php _e('Upload an image', 'bp-cover');?>'/> 
  90. <a href="#" class="remove-btn button" ><?php _e('Delete', 'bp-cover');?></a><?php 
  91. if(!empty($cover_group)):  
  92. ?> 
  93. <td><img src='<?php print esc_url( $cover_group ); ?>' class='preview-upload' /></td>  
  94. <?php else :?> 
  95. <td><p style="font-size:10px; color:#ccc;" ><?php _e('Please upload an image', 'bp-cover');?></p> </td> 
  96. <?php endif ?> 
  97. </span>  
  98. </td>  
  99. </tr> 
  100.  
  101. <tr>  
  102. <td><input type="submit" name="bp_cover_submit" value="<?php _e('Save', 'bp-cover');?>" class="button button-primary" /></td> 
  103. </tr> 
  104. </table> 
  105. </form> 
  106. </div> 
  107.  
  108. <div data-content="2" class="content "> 
  109. <td><?php _e('Skins for cover', 'bp-cover');?></td> 
  110. <form action="" method="post">  
  111. <tr class="cover-group">  
  112. <td> 
  113. <?php 
  114. $op = get_option('bp_cover_skin'); 
  115. if (is_dir(BP_COVER_TEMPLATES_DIR)) { 
  116. if ($dh = opendir(BP_COVER_TEMPLATES_DIR)) {  
  117. echo "<table width='100%' border='0' cellspacing='5' cellpadding='5'> 
  118. <thead> 
  119. <tr> 
  120. <th>".__("Screenshot", "bp-cover")."</th> 
  121. <th >".__("Name", "bp-cover")."</th> 
  122. <th >".__("Version", "bp-cover")."</th> 
  123. <th >".__("Description", "bp-cover")."</th> 
  124. <th >".__("Action", "bp-cover")."</th> 
  125.  
  126. </tr> 
  127. </thead>"; 
  128. while (($file = readdir($dh)) !== false) { 
  129. if(filetype(BP_COVER_TEMPLATES_DIR . $file) == "dir" && $file != ".." && $file != "." && substr($file, 0, 1) != ".") { 
  130. $p = file_get_contents(BP_COVER_TEMPLATES_DIR.$file."/css/style.css"); 
  131. $class = ($class == "alternate")?"":"alternate"; 
  132. echo "<tr class='$class'> 
  133. <td>".get_skinscreenshot($file)."</td> 
  134. <td>".get_skinmeta('Name', $p)."</td> 
  135. <td>".get_skinmeta('Version', $p)."</td> 
  136. <td>".get_skinmeta('Description', $p)."</td>"; 
  137. if($op == $file) { 
  138. echo "<td>In Use</td></tr>"; 
  139. }else{ 
  140. echo "<td><input type='radio' name='bp_cover_skin' value='". $file ."' /></td></tr>"; 
  141. echo "</table>";?>  
  142. </td>  
  143.  
  144. </tr> 
  145. <tr>  
  146. <td><input type="submit" name="bp_cover_submit_skin" value="<?php _e('Save', 'bp-cover');?>" class="button button-primary" /></td> 
  147. </tr> 
  148. </form> 
  149. </div>  
  150. <div data-content="3" class="content"> 
  151. <div class="addons_wrap"> 
  152. <h2><?php _e( 'Other plugins', 'bp-cover' ); ?><a href="http://bp.webcaffe.ir/shop" class="add-new-h2"><?php _e( 'See all plugins', 'bp-cover' ); ?></a></h2> 
  153. <?php 
  154. if ( false === ( $addons = get_transient( 'wbb_addons_data' ) ) ) { 
  155. $addons_json = wp_remote_get( 'http://webcaffe.ir/wp-content/uploads/json/wb-addons.json', array( 'user-agent' => 'WBB Addons Page' ) ); 
  156. if ( ! is_wp_error( $addons_json ) ) { 
  157. $addons = json_decode( wp_remote_retrieve_body( $addons_json ) ); 
  158. if ( $addons ) { 
  159. set_transient( 'wbb_addons_data', $addons, 60*60*24*7 ); 
  160. if ( $addons ) : ?> 
  161. <div id="the-list">  
  162. <?php 
  163. foreach ( $addons as $addon ) {  
  164. echo '<div class="plugin-card"> 
  165. <div class="plugin-card-top">';  
  166. echo '<a href="' . $addon->link . '" class=" plugin-icon">'; 
  167. if ( ! empty( $addon->image ) ) { 
  168. echo '<img src="' . $addon->image . '"/></a>'; 
  169. } else { 
  170. echo '<img src="' . BPCO_PLUGIN_URL . 'images/plugins.jpg"/></a>'; 
  171. echo '<div class="name column-name"><h4><a href="' . $addon->link . '">' . $addon->title . '</a></h4></div>'; 
  172. echo '<div class="action-links"><ul class="plugin-action-buttons"> 
  173. <li><span class="button button-disabled" title="price">' . $addon->price . '</span></li> 
  174. <li><a href="' . $addon->link . '" class="button">Buy</a></li> 
  175. </div>'; 
  176. echo '<div class="desc column-description"><p>' . $addon->excerpt . '</p></div>'; 
  177. echo '</div></div>'; 
  178. ?>  
  179. </div>  
  180. <?php else : ?> 
  181. <p><?php printf( __( 'Our catalog of WP Product can be found on webcaffe.ir here: <a href="%s">WP Product </a>', 'bp-cover' ), 'http://bp.webcaffe.ir/shop/' ); ?></p> 
  182. <?php endif; ?> 
  183. </div> 
  184. </div>  
  185. </div> 
  186. </div> 
  187. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
  188. <script> 
  189. $(function () { 
  190.  
  191. $('[data-tab]').on('click', function (e) { 
  192. $(this) 
  193. .addClass('active') 
  194. .siblings('[data-tab]') 
  195. .removeClass('active') 
  196. .siblings('[data-content=' + $(this).data('tab') + ']') 
  197. .addClass('active') 
  198. .siblings('[data-content]') 
  199. .removeClass('active'); 
  200. e.preventDefault(); 
  201. }); 
  202.  
  203. }); 
  204. </script> 
  205. <?php