BuddyPress_First_Letter_Avatar_Config

The BuddyPress First Letter Avatar BuddyPress First Letter Avatar Config class.

Defined (1)

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

/buddypress-first-letter-avatar-config.php  
  1. class BuddyPress_First_Letter_Avatar_Config { 
  2.  
  3.  
  4. private $options; 
  5.  
  6.  
  7. public function __construct() { 
  8.  
  9. add_action('admin_menu', array($this, 'add_admin_menu')); // add plugin settings page 
  10. add_action('admin_init', array($this, 'settings_init')); // create plugin settings page content 
  11.  
  12.  
  13.  
  14.  
  15. /**  
  16. * Add plugin settings page 
  17. */ 
  18. public function add_admin_menu() { 
  19.  
  20. add_options_page('BuddyPress First Letter Avatar', 'BuddyPress First Letter Avatar', 'manage_options', 'buddypress_first_letter_avatar', array($this, 'options_page')); 
  21.  
  22.  
  23.  
  24.  
  25. /**  
  26. * Create plugin settings page content 
  27. */ 
  28. public function settings_init() { 
  29.  
  30. register_setting('bpfla_pluginPage', 'bpfla_settings'); 
  31.  
  32. add_settings_section( 
  33. 'bpfla_pluginPage_section',  
  34. __('Plugin configuration', 'buddypress-first-letter-avatar'),  
  35. array($this, 'settings_section_callback'),  
  36. 'bpfla_pluginPage' 
  37. ); 
  38.  
  39. add_settings_field( 
  40. 'bpfla_letter_index',  
  41. __('Letter index', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' 0',  
  42. array($this, 'letter_index_render'),  
  43. 'bpfla_pluginPage',  
  44. 'bpfla_pluginPage_section' 
  45. ); 
  46.  
  47. add_settings_field( 
  48. 'bpfla_file_format',  
  49. __('File format', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' png',  
  50. array($this, 'file_format_render'),  
  51. 'bpfla_pluginPage',  
  52. 'bpfla_pluginPage_section' 
  53. ); 
  54.  
  55. add_settings_field( 
  56. 'bpfla_unknown_image',  
  57. __('Unknown image name', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' mystery',  
  58. array($this, 'unknown_image_render'),  
  59. 'bpfla_pluginPage',  
  60. 'bpfla_pluginPage_section' 
  61. ); 
  62.  
  63. add_settings_field( 
  64. 'bpfla_avatar_set',  
  65. __('Avatar set', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' default',  
  66. array($this, 'avatar_set_render'),  
  67. 'bpfla_pluginPage',  
  68. 'bpfla_pluginPage_section' 
  69. ); 
  70.  
  71. add_settings_field( 
  72. 'bpfla_use_profile_avatar',  
  73. __("Use users' and groups' avatars", 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' ' . __('check', 'buddypress-first-letter-avatar'),  
  74. array($this, 'use_profile_avatar_render'),  
  75. 'bpfla_pluginPage',  
  76. 'bpfla_pluginPage_section' 
  77. ); 
  78.  
  79. add_settings_field( 
  80. 'bpfla_use_gravatar',  
  81. __('Use Gravatar', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' ' . __('check', 'buddypress-first-letter-avatar'),  
  82. array($this, 'use_gravatar_render'),  
  83. 'bpfla_pluginPage',  
  84. 'bpfla_pluginPage_section' 
  85. ); 
  86.  
  87. add_settings_field( 
  88. 'bpfla_round_avatars',  
  89. __('Round avatars', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' ' . __('uncheck', 'buddypress-first-letter-avatar'),  
  90. array($this, 'round_avatars_render'),  
  91. 'bpfla_pluginPage',  
  92. 'bpfla_pluginPage_section' 
  93. ); 
  94.  
  95. add_settings_field( 
  96. 'bpfla_filter_priority',  
  97. __('Plugin filter priority', 'buddypress-first-letter-avatar') . '<br/>' . __('Default:', 'buddypress-first-letter-avatar') . ' 10',  
  98. array($this, 'filter_priority_render'),  
  99. 'bpfla_pluginPage',  
  100. 'bpfla_pluginPage_section' 
  101. ); 
  102.  
  103.  
  104.  
  105.  
  106. /**  
  107. * Below methods are responsible for rendering each settings field 
  108. */ 
  109. public function letter_index_render() { 
  110.  
  111. ?> 
  112. <input style="width:40px;" type='text' name='bpfla_settings[bpfla_letter_index]' value='<?php if (array_key_exists('bpfla_letter_index', $this->options)) echo $this->options['bpfla_letter_index']; ?>' /> 
  113. <?php 
  114.  
  115. public function file_format_render() { 
  116.  
  117. ?> 
  118. <input style="width: 100px;" type='text' name='bpfla_settings[bpfla_file_format]' value='<?php if (array_key_exists('bpfla_file_format', $this->options)) echo $this->options['bpfla_file_format']; ?>' /> 
  119. <?php 
  120.  
  121. public function unknown_image_render() { 
  122.  
  123. ?> 
  124. <input type='text' name='bpfla_settings[bpfla_unknown_image]' value='<?php if (array_key_exists('bpfla_unknown_image', $this->options)) echo $this->options['bpfla_unknown_image']; ?>' /> 
  125. <?php 
  126.  
  127. public function avatar_set_render() { 
  128.  
  129. ?> 
  130. <input type='text' name='bpfla_settings[bpfla_avatar_set]' value='<?php if (array_key_exists('bpfla_avatar_set', $this->options)) echo $this->options['bpfla_avatar_set']; ?>' /> 
  131. <?php 
  132.  
  133. public function use_profile_avatar_render() { 
  134.  
  135. ?> 
  136. <input type='checkbox' name='bpfla_settings[bpfla_use_profile_avatar]' <?php if (array_key_exists('bpfla_use_profile_avatar', $this->options)) checked($this->options['bpfla_use_profile_avatar'], 1); ?> value='1' /> 
  137. <?php 
  138.  
  139. public function use_gravatar_render() { 
  140.  
  141. ?> 
  142. <input type='checkbox' name='bpfla_settings[bpfla_use_gravatar]' <?php if (array_key_exists('bpfla_use_gravatar', $this->options)) checked($this->options['bpfla_use_gravatar'], 1); ?> value='1' /> 
  143. <?php 
  144.  
  145. public function round_avatars_render() { 
  146.  
  147. ?> 
  148. <input type='checkbox' name='bpfla_settings[bpfla_round_avatars]' <?php if (array_key_exists('bpfla_round_avatars', $this->options)) checked($this->options['bpfla_round_avatars'], 1); ?> value='1' /> 
  149. <?php 
  150.  
  151. public function filter_priority_render() { 
  152.  
  153. ?> 
  154. <input type='text' name='bpfla_settings[bpfla_filter_priority]' value='<?php if (array_key_exists('bpfla_filter_priority', $this->options)) echo $this->options['bpfla_filter_priority']; ?>' /> 
  155. <?php 
  156.  
  157.  
  158.  
  159.  
  160. /**  
  161. * Get plugin options from database 
  162. */ 
  163. public function settings_section_callback() { 
  164.  
  165. $this->options = get_option('bpfla_settings'); 
  166.  
  167.  
  168.  
  169.  
  170. /**  
  171. * Create a settings form 
  172. */ 
  173. public function options_page() { 
  174.  
  175. ?> 
  176. <form action='options.php' method='post'> 
  177.  
  178. <h2>BuddyPress First Letter Avatar</h2> 
  179.  
  180. <?php 
  181. settings_fields('bpfla_pluginPage'); 
  182. do_settings_sections('bpfla_pluginPage'); 
  183. submit_button(); 
  184. ?> 
  185.  
  186. <hr /> 
  187.  
  188. <h3><?php _e('Fields description:', 'buddypress-first-letter-avatar'); ?></h3> 
  189. <p> 
  190. <strong><?php _e('Letter index', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  191. <?php echo sprintf(__('%s use first letter for the avatar; %s use second letter; %s use last letter, etc.', 'buddypress-first-letter-avatar'),  
  192. '<span style="text-decoration: underline">0</span>:', '<span style="text-decoration: underline">1</span>:', '<span style="text-decoration: underline">-1</span>:'); ?> 
  193. </p> 
  194. <p> 
  195. <strong><?php _e('File format', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  196. <?php echo sprintf(__('File format of your avatars, for example %s or %s.', 'buddypress-first-letter-avatar'),  
  197. '<span style="text-decoration: underline">png</span>', '<span style="text-decoration: underline">jpg</span>'); ?> 
  198. </p> 
  199. <p> 
  200. <strong><?php _e('Unknown image name', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  201. <?php _e('Name of the file used for unknown usernames (without extension).', 'buddypress-first-letter-avatar'); ?>  
  202. </p> 
  203. <p> 
  204. <strong><?php _e('Avatar set', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  205. <?php _e('Directory where your avatars are stored.', 'buddypress-first-letter-avatar'); ?>  
  206. </p> 
  207. <p> 
  208. <strong><?php _e("Use users' and groups' avatars", 'buddypress-first-letter-avatar'); ?></strong><br /> 
  209. <?php echo sprintf(__("%sCheck%s: use users' and groups' avatars when available; %sUncheck%s: use Gravatar or custom avatars.", 'buddypress-first-letter-avatar'),  
  210. '<span style="text-decoration: underline">', '</span>', '<span style="text-decoration: underline">', '</span>'); ?> 
  211. </p> 
  212. <p> 
  213. <strong><?php _e('Use Gravatar', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  214. <?php echo sprintf(__("%sCheck%s: use Gravatar when available; %sUncheck%s: use users' profile avatars or custom avatars.", 'buddypress-first-letter-avatar'),  
  215. '<span style="text-decoration: underline">', '</span>', '<span style="text-decoration: underline">', '</span>'); ?> 
  216. </p> 
  217. <p> 
  218. <strong><?php _e('Round avatars', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  219. <?php echo sprintf(__('%sCheck%s: use rounded avatars; %sUncheck%s: use standard avatars. This may not always work - your theme may override this setting.', 'buddypress-first-letter-avatar'),  
  220. '<span style="text-decoration: underline">', '</span>', '<span style="text-decoration: underline">', '</span>'); ?> 
  221. </p> 
  222. <p> 
  223. <strong><?php _e('Filter priority', 'buddypress-first-letter-avatar'); ?></strong><br /> 
  224. <?php _e('If you are using multiple avatar plugins, you can increase or decrease execution priority of this plugin. If BuddyPress First Letter Avatar is overriding your other plugins, try changing this to a lower value (for example 9).', 'buddypress-first-letter-avatar'); ?> 
  225. </p> 
  226. <p><?php _e('In case of any problems, please use default values.', 'buddypress-first-letter-avatar'); ?></p> 
  227.  
  228. <hr /> 
  229.  
  230. <p style="text-align: right; margin-right:30px"><?php  
  231. $ending_text = sprintf(__('If you like the plugin, please <a href="%s">leave a rating in WordPress Plugin Directory</a>!', 'buddypress-first-letter-avatar'), 'https://wordpress.org/support/view/plugin-reviews/buddypress-first-letter-avatar#postform'); 
  232. $ending_text .= '<br />'; 
  233. $ending_text .= sprintf(__('BuddyPress First Letter Avatar was created by <a href="%s">Daniel Wroblewski</a>', 'buddypress-first-letter-avatar'), 'http://dev49.net/'); 
  234. echo $ending_text; 
  235. ?></p> 
  236.  
  237. </form> 
  238. <?php 
  239.  
  240.