class-simple-author-box-admin-page.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. <?php
  2. class Simple_Author_Box_Admin_Page {
  3. private $tab;
  4. private $options;
  5. private $sections;
  6. private $views_path;
  7. function __construct() {
  8. $this->views_path = SIMPLE_AUTHOR_BOX_PATH . 'inc/admin/';
  9. $default_sections = array(
  10. 'general-options' => array(
  11. 'label' => __( 'Settings', 'saboxplugin' ),
  12. ),
  13. 'appearance-options' => array(
  14. 'label' => __( 'Appearance', 'saboxplugin' ),
  15. ),
  16. 'color-options' => array(
  17. 'label' => __( 'Colors', 'saboxplugin' ),
  18. ),
  19. 'typography-options' => array(
  20. 'label' => __( 'Typography', 'saboxplugin' ),
  21. ),
  22. 'miscellaneous-options' => array(
  23. 'label' => __( 'Misc', 'saboxplugin' ),
  24. ),
  25. 'upgrade-pro' => array(
  26. 'label' => esc_html__( 'Upgrade', 'saboxplugin' ),
  27. 'link' => admin_url( 'admin.php?page=sab-upgrade' ),
  28. 'class' => 'upgrade-pro',
  29. ),
  30. );
  31. $settings = array(
  32. 'general-options' => array(
  33. 'sab_autoinsert' => array(
  34. 'label' => __( 'Manually insert the Simple Author Box', 'saboxplugin' ),
  35. 'description' => __( 'When turned ON, the author box will no longer be automatically added to your post. You\'ll need to manually add it using shortcodes or a PHP function.', 'saboxplugin' ),
  36. 'type' => 'toggle',
  37. 'group' => 'saboxplugin_options',
  38. ),
  39. 'plugin_code' => array(
  40. 'label' => __( 'If you want to manually insert the Simple Author Box in your template file (single post view), you can use the following code snippet', 'saboxplugin' ),
  41. 'type' => 'readonly',
  42. 'value' => '&lt;?php if ( function_exists( \'wpsabox_author_box\' ) ) echo wpsabox_author_box(); ?&gt;',
  43. 'condition' => 'sab_autoinsert',
  44. ),
  45. 'plugin_shortcode' => array(
  46. 'label' => __( 'If you want to manually insert the Simple Author Box in your post content, you can use the following shortcode', 'saboxplugin' ),
  47. 'type' => 'readonly',
  48. 'value' => '[simple-author-box]',
  49. 'condition' => 'sab_autoinsert',
  50. ),
  51. 'sab_no_description' => array(
  52. 'label' => __( 'Hide the author box if author description is empty', 'saboxplugin' ),
  53. 'description' => __( 'When turned ON, the author box will not appear for users without a description', 'saboxplugin' ),
  54. 'type' => 'toggle',
  55. 'group' => 'saboxplugin_options',
  56. ),
  57. 'sab_email' => array(
  58. 'label' => __( 'Show author email', 'saboxplugin' ),
  59. 'description' => __( 'When turned ON, the plugin will add an email option next to the social icons.', 'saboxplugin' ),
  60. 'type' => 'toggle',
  61. 'group' => 'saboxplugin_options',
  62. ),
  63. 'sab_link_target' => array(
  64. 'label' => __( 'Open social icon links in a new tab', 'saboxplugin' ),
  65. 'description' => __( 'When turned ON, the author’s social links will open in a new tab.', 'saboxplugin' ),
  66. 'type' => 'toggle',
  67. 'group' => 'saboxplugin_options',
  68. ),
  69. 'sab_hide_socials' => array(
  70. 'label' => __( 'Hide the social icons on author box', 'saboxplugin' ),
  71. 'description' => __( 'When turned ON, the author’s social icons will be hidden.', 'saboxplugin' ),
  72. 'type' => 'toggle',
  73. 'group' => 'saboxplugin_options',
  74. ),
  75. ),
  76. 'appearance-options' => array(
  77. 'sab_box_margin_top' => array(
  78. 'label' => __( 'Top margin of author box', 'saboxplugin' ),
  79. 'description' => __( 'Choose how much space to add above the author box', 'saboxplugin' ),
  80. 'type' => 'slider',
  81. 'choices' => array(
  82. 'min' => 0,
  83. 'max' => 100,
  84. 'increment' => 1,
  85. ),
  86. 'default' => '0',
  87. ),
  88. 'sab_box_margin_bottom' => array(
  89. 'label' => __( 'Bottom margin of author box', 'saboxplugin' ),
  90. 'description' => __( 'Choose how much space to add below the author box', 'saboxplugin' ),
  91. 'type' => 'slider',
  92. 'choices' => array(
  93. 'min' => 0,
  94. 'max' => 100,
  95. 'increment' => 1,
  96. ),
  97. 'default' => '0',
  98. ),
  99. 'sab_box_padding_top_bottom' => array(
  100. 'label' => __( 'Padding top and bottom of author box', 'saboxplugin' ),
  101. 'description' => __( 'This controls the padding top & bottom of the author box', 'saboxplugin' ),
  102. 'type' => 'slider',
  103. 'choices' => array(
  104. 'min' => 0,
  105. 'max' => 100,
  106. 'increment' => 1,
  107. ),
  108. 'default' => '0',
  109. ),
  110. 'sab_box_padding_left_right' => array(
  111. 'label' => __( 'Padding left and right of author box', 'saboxplugin' ),
  112. 'description' => __( 'This controls the padding left & right of the author box', 'saboxplugin' ),
  113. 'type' => 'slider',
  114. 'choices' => array(
  115. 'min' => 0,
  116. 'max' => 100,
  117. 'increment' => 1,
  118. ),
  119. 'default' => '0',
  120. ),
  121. 'sab_box_border_width' => array(
  122. 'label' => __( 'Border Width', 'saboxplugin' ),
  123. 'description' => __( 'This controls the border width of the author box', 'saboxplugin' ),
  124. 'type' => 'slider',
  125. 'choices' => array(
  126. 'min' => 0,
  127. 'max' => 100,
  128. 'increment' => 1,
  129. ),
  130. 'default' => '1',
  131. 'group' => 'saboxplugin_options',
  132. ),
  133. 'sab_avatar_style' => array(
  134. 'label' => __( 'Author avatar image style', 'saboxplugin' ),
  135. 'description' => __( 'Change the shape of the author’s avatar image', 'saboxplugin' ),
  136. 'type' => 'select',
  137. 'choices' => array(
  138. 0 => __( 'Square', 'saboxplugin' ),
  139. 1 => __( 'Circle', 'saboxplugin' ),
  140. ),
  141. 'default' => '0',
  142. 'group' => 'saboxplugin_options',
  143. ),
  144. 'sab_avatar_hover' => array(
  145. 'label' => __( 'Rotate effect on author avatar hover', 'saboxplugin' ),
  146. 'description' => __( 'When turned ON, this adds a rotate effect when hovering over the author\'s avatar', 'saboxplugin' ),
  147. 'type' => 'toggle',
  148. 'group' => 'saboxplugin_options',
  149. 'condition' => 'sab_avatar_style',
  150. ),
  151. 'sab_web' => array(
  152. 'label' => __( 'Show author website', 'saboxplugin' ),
  153. 'description' => __( 'When turned ON, the box will include the author\'s website', 'saboxplugin' ),
  154. 'type' => 'toggle',
  155. 'group' => 'saboxplugin_options',
  156. ),
  157. 'sab_web_target' => array(
  158. 'label' => __( 'Open author website link in a new tab', 'saboxplugin' ),
  159. 'description' => __( 'If you check this the author\'s link will open in a new tab', 'saboxplugin' ),
  160. 'type' => 'toggle',
  161. 'condition' => 'sab_web',
  162. 'group' => 'saboxplugin_options',
  163. ),
  164. 'sab_web_rel' => array(
  165. 'label' => __( 'Add "nofollow" attribute on author website link', 'saboxplugin' ),
  166. 'description' => __( 'Toggling this to ON will make the author website have the no-follow parameter added.', 'saboxplugin' ),
  167. 'type' => 'toggle',
  168. 'condition' => 'sab_web',
  169. 'group' => 'saboxplugin_options',
  170. ),
  171. 'sab_web_position' => array(
  172. 'label' => __( 'Author website position', 'saboxplugin' ),
  173. 'description' => __( 'Select where you want to show the website ( left or right )', 'saboxplugin' ),
  174. 'type' => 'select',
  175. 'choices' => array(
  176. 0 => __( 'Left', 'saboxplugin' ),
  177. 1 => __( 'Right', 'saboxplugin' ),
  178. ),
  179. 'default' => '0',
  180. 'condition' => 'sab_web',
  181. 'group' => 'saboxplugin_options',
  182. ),
  183. 'sab_colored' => array(
  184. 'label' => __( 'Social icons type', 'saboxplugin' ),
  185. 'description' => __( 'Colored background adds a background behind the social icon symbol', 'saboxplugin' ),
  186. 'type' => 'select',
  187. 'choices' => array(
  188. 0 => __( 'Symbols', 'saboxplugin' ),
  189. 1 => __( 'Colored', 'saboxplugin' ),
  190. ),
  191. 'default' => '0',
  192. 'group' => 'saboxplugin_options',
  193. ),
  194. 'sab_icons_style' => array(
  195. 'label' => __( 'Social icons style', 'saboxplugin' ),
  196. 'description' => __( 'Select the shape of social icons\' container', 'saboxplugin' ),
  197. 'type' => 'select',
  198. 'choices' => array(
  199. 0 => __( 'Squares', 'saboxplugin' ),
  200. 1 => __( 'Circle', 'saboxplugin' ),
  201. ),
  202. 'default' => '0',
  203. 'condition' => 'sab_colored',
  204. 'group' => 'saboxplugin_options',
  205. ),
  206. 'sab_social_hover' => array(
  207. 'label' => __( 'Rotate effect on social icons hover (works only for circle icons)', 'saboxplugin' ),
  208. 'description' => __( 'Add a rotate effect when you hover on social icons hover', 'saboxplugin' ),
  209. 'type' => 'toggle',
  210. 'condition' => 'sab_colored',
  211. 'group' => 'saboxplugin_options',
  212. ),
  213. 'sab_box_long_shadow' => array(
  214. 'label' => __( 'Use flat long shadow effect', 'saboxplugin' ),
  215. 'description' => __( 'Check this if you want a flat shodow for social icons', 'saboxplugin' ),
  216. 'type' => 'toggle',
  217. 'condition' => 'sab_colored',
  218. 'group' => 'saboxplugin_options',
  219. ),
  220. 'sab_box_thin_border' => array(
  221. 'label' => __( 'Show a thin border on colored social icons', 'saboxplugin' ),
  222. 'description' => __( 'Add a border to social icons container.', 'saboxplugin' ),
  223. 'type' => 'toggle',
  224. 'condition' => 'sab_colored',
  225. 'group' => 'saboxplugin_options',
  226. ),
  227. ),
  228. 'color-options' => array(
  229. 'sab_box_author_color' => array(
  230. 'label' => __( 'Author name color', 'saboxplugin' ),
  231. 'description' => __( 'Select the color for author\'s name text', 'saboxplugin' ),
  232. 'type' => 'color',
  233. 'group' => 'saboxplugin_options',
  234. ),
  235. 'sab_box_web_color' => array(
  236. 'label' => __( 'Author website link color', 'saboxplugin' ),
  237. 'description' => __( 'Select the color for author\'s website link', 'saboxplugin' ),
  238. 'type' => 'color',
  239. 'group' => 'saboxplugin_options',
  240. 'condition' => 'sab_web',
  241. ),
  242. 'sab_box_border' => array(
  243. 'label' => __( 'Border color', 'saboxplugin' ),
  244. 'description' => __( 'Select the color for author box border', 'saboxplugin' ),
  245. 'type' => 'color',
  246. 'group' => 'saboxplugin_options',
  247. ),
  248. 'sab_box_icons_back' => array(
  249. 'label' => __( 'Background color of social icons bar', 'saboxplugin' ),
  250. 'description' => __( 'Select the color for the social icons bar background', 'saboxplugin' ),
  251. 'type' => 'color',
  252. 'group' => 'saboxplugin_options',
  253. ),
  254. 'sab_box_author_back' => array(
  255. 'label' => __( 'Background color of author box', 'saboxplugin' ),
  256. 'description' => __( 'Select the color for the author box background', 'saboxplugin' ),
  257. 'type' => 'color',
  258. 'group' => 'saboxplugin_options',
  259. ),
  260. 'sab_box_author_p_color' => array(
  261. 'label' => __( 'Color of author box paragraphs', 'saboxplugin' ),
  262. 'description' => __( 'Select the color for the author box paragraphs', 'saboxplugin' ),
  263. 'type' => 'color',
  264. 'group' => 'saboxplugin_options',
  265. ),
  266. 'sab_box_author_a_color' => array(
  267. 'label' => __( 'Color of author box links', 'saboxplugin' ),
  268. 'description' => __( 'Select the color for the author box links', 'saboxplugin' ),
  269. 'type' => 'color',
  270. 'group' => 'saboxplugin_options',
  271. ),
  272. 'sab_box_icons_color' => array(
  273. 'label' => __( 'Social icons color (for symbols only)', 'saboxplugin' ),
  274. 'description' => __( 'Select the color for social icons when using the symbols only social icon type', 'saboxplugin' ),
  275. 'type' => 'color',
  276. 'group' => 'saboxplugin_options',
  277. ),
  278. ),
  279. 'typography-options' => array(
  280. 'sab_box_subset' => array(
  281. 'label' => __( 'Google font characters subset', 'saboxplugin' ),
  282. 'description' => __( 'Note - Some Google Fonts do not support particular subsets', 'saboxplugin' ),
  283. 'type' => 'select',
  284. 'choices' => Simple_Author_Box_Helper::get_google_font_subsets(),
  285. 'default' => 'none',
  286. ),
  287. 'sab_box_name_font' => array(
  288. 'label' => __( 'Author name font family', 'saboxplugin' ),
  289. 'description' => __( 'Select the font family for the author\'s name', 'saboxplugin' ),
  290. 'type' => 'select',
  291. 'choices' => Simple_Author_Box_Helper::get_google_fonts(),
  292. 'default' => 'None',
  293. ),
  294. 'sab_box_web_font' => array(
  295. 'label' => __( 'Author website font family', 'saboxplugin' ),
  296. 'description' => __( 'Select the font family for the author\'s website', 'saboxplugin' ),
  297. 'type' => 'select',
  298. 'choices' => Simple_Author_Box_Helper::get_google_fonts(),
  299. 'default' => 'None',
  300. 'condition' => 'sab_web',
  301. ),
  302. 'sab_box_desc_font' => array(
  303. 'label' => __( 'Author description font family', 'saboxplugin' ),
  304. 'description' => __( 'Select the font family for the author\'s description', 'saboxplugin' ),
  305. 'type' => 'select',
  306. 'choices' => Simple_Author_Box_Helper::get_google_fonts(),
  307. 'default' => 'None',
  308. ),
  309. 'sab_box_name_size' => array(
  310. 'label' => __( 'Author name font size', 'saboxplugin' ),
  311. 'description' => __( 'Default font size for author name is 18px.', 'saboxplugin' ),
  312. 'type' => 'slider',
  313. 'choices' => array(
  314. 'min' => 10,
  315. 'max' => 50,
  316. 'increment' => 1,
  317. ),
  318. 'default' => '18',
  319. ),
  320. 'sab_box_web_size' => array(
  321. 'label' => __( 'Author website font size', 'saboxplugin' ),
  322. 'description' => __( 'Default font size for author website is 14px.', 'saboxplugin' ),
  323. 'type' => 'slider',
  324. 'choices' => array(
  325. 'min' => 10,
  326. 'max' => 50,
  327. 'increment' => 1,
  328. ),
  329. 'default' => '14',
  330. 'condition' => 'sab_web',
  331. ),
  332. 'sab_box_desc_size' => array(
  333. 'label' => __( 'Author description font size', 'saboxplugin' ),
  334. 'description' => __( 'Default font size for author description is 14px.', 'saboxplugin' ),
  335. 'type' => 'slider',
  336. 'choices' => array(
  337. 'min' => 10,
  338. 'max' => 50,
  339. 'increment' => 1,
  340. ),
  341. 'default' => '14',
  342. ),
  343. 'sab_box_icon_size' => array(
  344. 'label' => __( 'Size of social icons', 'saboxplugin' ),
  345. 'description' => __( 'Default font size for social icons is 18px.', 'saboxplugin' ),
  346. 'type' => 'slider',
  347. 'choices' => array(
  348. 'min' => 10,
  349. 'max' => 50,
  350. 'increment' => 1,
  351. ),
  352. 'default' => '18',
  353. ),
  354. 'sab_desc_style' => array(
  355. 'label' => __( 'Author description font style', 'saboxplugin' ),
  356. 'description' => __( 'Select the font style for the author\'s description', 'saboxplugin' ),
  357. 'type' => 'select',
  358. 'choices' => array(
  359. 0 => __( 'Normal', 'saboxplugin' ),
  360. 1 => __( 'Italic', 'saboxplugin' ),
  361. ),
  362. 'default' => '0',
  363. 'group' => 'saboxplugin_options',
  364. ),
  365. ),
  366. 'miscellaneous-options' => array(
  367. 'sab_footer_inline_style' => array(
  368. 'label' => __( 'Load generated inline style to footer', 'saboxplugin' ),
  369. 'description' => __( 'This option is useful ONLY if you run a plugin that optimizes your CSS delivery or moves your stylesheets to the footer, to get a higher score on speed testing services. However, the plugin style is loaded only on single post and single page.', 'saboxplugin' ),
  370. 'type' => 'toggle',
  371. 'group' => 'saboxplugin_options',
  372. ),
  373. ),
  374. );
  375. $this->settings = apply_filters( 'sabox_admin_settings', $settings );
  376. $this->sections = apply_filters( 'sabox_admin_sections', $default_sections );
  377. $this->get_all_options();
  378. add_action( 'admin_menu', array( $this, 'menu_page' ) );
  379. add_action( 'admin_init', array( $this, 'save_settings' ) );
  380. }
  381. private function get_all_options() {
  382. $this->options = Simple_Author_Box_Helper::get_option( 'saboxplugin_options' );
  383. $sab_box_margin_top = Simple_Author_Box_Helper::get_option( 'sab_box_margin_top' );
  384. if ( $sab_box_margin_top ) {
  385. $this->options['sab_box_margin_top'] = $sab_box_margin_top;
  386. }
  387. $sab_box_margin_bottom = Simple_Author_Box_Helper::get_option( 'sab_box_margin_bottom' );
  388. if ( $sab_box_margin_bottom ) {
  389. $this->options['sab_box_margin_bottom'] = $sab_box_margin_bottom;
  390. }
  391. $sab_box_icon_size = Simple_Author_Box_Helper::get_option( 'sab_box_icon_size' );
  392. if ( $sab_box_icon_size ) {
  393. $this->options['sab_box_icon_size'] = $sab_box_icon_size;
  394. }
  395. $sab_box_author_font_size = Simple_Author_Box_Helper::get_option( 'sab_box_name_size' );
  396. if ( $sab_box_author_font_size ) {
  397. $this->options['sab_box_name_size'] = $sab_box_author_font_size;
  398. }
  399. $sab_box_web_size = Simple_Author_Box_Helper::get_option( 'sab_box_web_size' );
  400. if ( $sab_box_web_size ) {
  401. $this->options['sab_box_web_size'] = $sab_box_web_size;
  402. }
  403. $sab_box_name_font = Simple_Author_Box_Helper::get_option( 'sab_box_name_font' );
  404. if ( $sab_box_name_font ) {
  405. $this->options['sab_box_name_font'] = $sab_box_name_font;
  406. }
  407. $sab_box_subset = Simple_Author_Box_Helper::get_option( 'sab_box_subset' );
  408. if ( $sab_box_subset ) {
  409. $this->options['sab_box_subset'] = $sab_box_subset;
  410. }
  411. $sab_box_desc_font = Simple_Author_Box_Helper::get_option( 'sab_box_desc_font' );
  412. if ( $sab_box_desc_font ) {
  413. $this->options['sab_box_desc_font'] = $sab_box_desc_font;
  414. }
  415. $sab_box_web_font = Simple_Author_Box_Helper::get_option( 'sab_box_web_font' );
  416. if ( $sab_box_web_font ) {
  417. $this->options['sab_box_web_font'] = $sab_box_web_font;
  418. }
  419. $sab_box_desc_size = Simple_Author_Box_Helper::get_option( 'sab_box_desc_size' );
  420. if ( $sab_box_desc_size ) {
  421. $this->options['sab_box_desc_size'] = $sab_box_desc_size;
  422. }
  423. $this->options['sab_box_padding_top_bottom'] = Simple_Author_Box_Helper::get_option( 'sab_box_padding_top_bottom' );
  424. $this->options['sab_box_padding_left_right'] = Simple_Author_Box_Helper::get_option( 'sab_box_padding_left_right' );
  425. }
  426. public function menu_page() {
  427. add_menu_page( __( 'Simple Author Box', 'saboxplugin' ), __( 'Simple Author', 'saboxplugin' ), 'manage_options', 'simple-author-box-options', array(
  428. $this,
  429. 'setting_page',
  430. ), SIMPLE_AUTHOR_BOX_ASSETS . 'img/sab-icon.png' );
  431. $show_upsell = apply_filters( 'sabox_show_upsell', true );
  432. if ( $show_upsell ) {
  433. add_submenu_page( 'simple-author-box-options', __( 'Upgrade to PRO', 'saboxplugin' ), __( 'Upgrade', 'saboxplugin' ), 'manage_options', 'sab-upgrade', array(
  434. $this,
  435. 'render_pro_page',
  436. ) );
  437. }
  438. }
  439. public function setting_page() {
  440. ?>
  441. <div class="masthead">
  442. <div class="wrap sabox-wrap">
  443. <div class="sabox-masthead-left">
  444. <h1 class="wp-heading-inline">
  445. <?php
  446. /* Translators: Welcome Screen Title. */
  447. echo esc_html( apply_filters( 'sabox_show_pro_title', __( 'Simple Author Box', 'saboxplugin' ) ) );
  448. ?>
  449. </h1>
  450. </div>
  451. <div class="sabox-masthead-right">
  452. <a target="_blank"
  453. href="https://www.machothemes.com/support/?utm_source=sab&utm_medium=about-page&utm_campaign=support-button"><?php _e( 'Support', 'saboxplugin' ); ?>
  454. &nbsp; &nbsp;<i class="dashicons dashicons-sos"></i>
  455. </a>
  456. </div>
  457. <div class="wp-clearfix"></div>
  458. </div>
  459. </div><!--/.masthead-->
  460. <div class="sabox-wrap">
  461. <div class="sabox-preview">
  462. <div class="sabox-preview-topbar">
  463. <a href="<?php echo get_edit_user_link(); ?>#your-profile" class="button button-secondary" target="_blank"><i class="dashicons dashicons-edit"></i><?php echo esc_html__( 'Edit Author Profile', 'saboxplugin' ); ?>
  464. </a>
  465. <a href="<?php echo get_edit_user_link(); ?>#sabox-custom-profile-image" class="button button-secondary" target="_blank"><i class="dashicons dashicons-admin-users"></i><?php echo esc_html__( 'Change Author Avatar', 'saboxplugin' ); ?>
  466. </a>
  467. <a href="<?php echo get_edit_user_link(); ?>#sabox-social-table" class="button button-secondary" target="_blank"><i class="dashicons dashicons-networking"></i><?php echo esc_html__( 'Add/Edit Social Media Icons', 'saboxplugin' ); ?>
  468. </a>
  469. </div><!--/.sabox-preview-topbar-->
  470. <?php do_action( 'sab_admin_preview' ) ?>
  471. </div>
  472. <h2 class="epfw-tab-wrapper nav-tab-wrapper wp-clearfix">
  473. <?php foreach ( $this->sections as $id => $section ) { ?>
  474. <?php
  475. $class = 'epfw-tab nav-tab';
  476. if ( isset( $section['link'] ) ) {
  477. $url = $section['link'];
  478. $class .= ' epfw-tab-link';
  479. } else {
  480. $url = '#' . $id;
  481. }
  482. if ( isset( $section['class'] ) ) {
  483. $class .= ' ' . $section['class'];
  484. }
  485. ?>
  486. <a class="<?php echo esc_attr( $class ); ?>"
  487. href="<?php echo esc_url( $url ); ?>"><?php echo wp_kses_post( $section['label'] ); ?></a>
  488. <?php } ?>
  489. </h2>
  490. <form method="post" id="sabox-container">
  491. <?php
  492. wp_nonce_field( 'sabox-plugin-settings', 'sabox_plugin_settings_page' );
  493. foreach ( $this->settings as $tab_name => $fields ) {
  494. echo '<div class="epfw-turn-into-tab" id="' . esc_attr( $tab_name ) . '-tab">';
  495. echo '<table class="form-table sabox-table">';
  496. foreach ( $fields as $field_name => $field ) {
  497. $this->generate_setting_field( $field_name, $field );
  498. }
  499. echo '</table>';
  500. echo '</div>';
  501. }
  502. echo '<div class="textright">';
  503. submit_button( esc_html__( 'Save Settings', 'saboxplugin' ), 'button button-primary button-hero', '', false );
  504. echo '</div>';
  505. ?>
  506. </form>
  507. </div>
  508. <span class="sabox-version">
  509. <?php echo _e( 'Version: ', 'saboxplugin' ) . esc_html( apply_filters( 'sabox_show_pro_version', SIMPLE_AUTHOR_BOX_VERSION ) ); ?>
  510. <?php
  511. $show_changelog = apply_filters( 'sabox_show_changelog', true );
  512. if ( $show_changelog ) {
  513. echo '&nbsp; &middot; &nbsp;';
  514. echo '<a target="_blank" href="https://github.com/MachoThemes/simple-author-box/blob/master/readme.txt">' . __( 'Changelog', 'saboxplugin' ) . '</a>';
  515. }
  516. ?>
  517. </span>
  518. <?php
  519. }
  520. public function save_settings() {
  521. if ( isset( $_POST['sabox_plugin_settings_page'] ) && wp_verify_nonce( $_POST['sabox_plugin_settings_page'], 'sabox-plugin-settings' ) ) {
  522. $settings = isset( $_POST['sabox-settings'] ) ? $_POST['sabox-settings'] : array();
  523. $groups = array();
  524. foreach ( $this->settings as $tab => $setting_fields ) {
  525. foreach ( $setting_fields as $key => $setting ) {
  526. if ( isset( $setting['group'] ) ) {
  527. if ( ! isset( $groups[ $setting['group'] ] ) ) {
  528. $groups[ $setting['group'] ] = get_option( $setting['group'], array() );
  529. }
  530. if ( ! isset( $settings[ $setting['group'] ][ $key ] ) && isset( $groups[ $setting['group'] ][ $key ] ) ) {
  531. $groups[ $setting['group'] ][ $key ] = '0';
  532. }
  533. if ( isset( $settings[ $setting['group'] ][ $key ] ) ) {
  534. $groups[ $setting['group'] ][ $key ] = $this->sanitize_fields( $setting, $settings[ $setting['group'] ][ $key ] );
  535. }
  536. } else {
  537. $current_value = get_option( $key );
  538. if ( isset( $settings[ $key ] ) ) {
  539. $value = $this->sanitize_fields( $setting, $settings[ $key ] );
  540. if ( $current_value != $value ) {
  541. update_option( $key, $value );
  542. }
  543. }
  544. }
  545. }
  546. }
  547. foreach ( $groups as $key => $values ) {
  548. update_option( $key, $values );
  549. }
  550. do_action( 'sabox_save_settings' );
  551. Simple_Author_Box_Helper::reset_options();
  552. $this->get_all_options();
  553. }
  554. }
  555. private function sanitize_fields( $setting, $value ) {
  556. $default_sanitizers = array(
  557. 'toggle' => 'absint',
  558. 'slider' => 'absint',
  559. 'color' => 'sanitize_hex_color',
  560. );
  561. if ( isset( $setting['sanitize'] ) && function_exists( $setting['sanitize'] ) ) {
  562. $value = call_user_func( $setting['sanitize'], $value );
  563. } elseif ( isset( $default_sanitizers[ $setting['type'] ] ) && function_exists( $default_sanitizers[ $setting['type'] ] ) ) {
  564. $value = call_user_func( $default_sanitizers[ $setting['type'] ], $value );
  565. } elseif ( 'select' == $setting['type'] ) {
  566. if ( isset( $setting['choices'][ $value ] ) ) {
  567. $value = $value;
  568. } else {
  569. $value = $setting['default'];
  570. }
  571. } elseif ( 'multiplecheckbox' == $setting['type'] ) {
  572. foreach ( $value as $key ) {
  573. if ( ! isset( $setting['choices'][ $key ] ) ) {
  574. unset( $value[ $key ] );
  575. }
  576. }
  577. } else {
  578. $value = sanitize_text_field( $value );
  579. }
  580. return $value;
  581. }
  582. private function generate_admin_url( $id ) {
  583. $url = 'admin.php?page=simple-author-box-options&tab=%1$s';
  584. return admin_url( sprintf( $url, $id ) );
  585. }
  586. private function generate_admin_path( $id ) {
  587. return $this->views_path . $id . '.php';
  588. }
  589. private function generate_setting_field( $field_name, $field ) {
  590. $class = '';
  591. $name = 'sabox-settings[';
  592. if ( isset( $field['group'] ) ) {
  593. $name .= $field['group'] . '][' . esc_attr( $field_name ) . ']';
  594. } else {
  595. $name .= esc_attr( $field_name ) . ']';
  596. }
  597. if ( isset( $field['condition'] ) ) {
  598. $class = 'show_if_' . $field['condition'] . ' hide';
  599. }
  600. echo '<tr valign="top" class="' . esc_attr( $class ) . '">';
  601. echo '<th scope="row">';
  602. if ( isset( $field['description'] ) ) {
  603. echo '<span class="epfw-tooltip tooltip-right" data-tooltip="' . esc_html( $field['description'] ) . '"><i class="dashicons dashicons-info"></i></span>';
  604. }
  605. echo esc_html( $field['label'] );
  606. echo '</th>';
  607. echo '<td>';
  608. switch ( $field['type'] ) {
  609. case 'toggle':
  610. $value = isset( $this->options[ $field_name ] ) ? $this->options[ $field_name ] : '0';
  611. echo '<div class="checkbox_switch">';
  612. echo '<div class="onoffswitch">';
  613. echo '<input type="checkbox" id="' . esc_attr( $field_name ) . '" name="' . esc_attr( $name ) . '" class="onoffswitch-checkbox saboxfield" ' . checked( 1, $value, false ) . ' value="1">';
  614. echo '<label class="onoffswitch-label" for="' . esc_attr( $field_name ) . '"></label>';
  615. echo '</div>';
  616. echo '</div>';
  617. break;
  618. case 'select':
  619. $value = isset( $this->options[ $field_name ] ) ? $this->options[ $field_name ] : $field['default'];
  620. echo '<select id="' . esc_attr( $field_name ) . '" name="' . esc_attr( $name ) . '" class="saboxfield">';
  621. foreach ( $field['choices'] as $key => $choice ) {
  622. echo '<option value="' . esc_attr( $key ) . '" ' . selected( $key, $value, false ) . '>' . esc_html( $choice ) . '</option>';
  623. }
  624. echo '</select>';
  625. break;
  626. case 'readonly':
  627. echo '<textarea clas="regular-text" rows="3" cols="50" onclick="this.focus();this.select();" readonly="readonly">' . esc_attr( $field['value'] ) . '</textarea>';
  628. break;
  629. case 'slider':
  630. $value = isset( $this->options[ $field_name ] ) ? $this->options[ $field_name ] : $field['default'];
  631. echo '<div class="sabox-slider-container slider-container">';
  632. echo '<input type="text" id="' . esc_attr( $field_name ) . '" class="saboxfield" name="' . esc_attr( $name ) . '" data-min="' . absint( $field['choices']['min'] ) . '" data-max="' . absint( $field['choices']['max'] ) . '" data-step="' . absint( $field['choices']['increment'] ) . '" value="' . esc_attr( $value ) . 'px">';
  633. echo '<div class="sabox-slider"></div>';
  634. echo '</div>';
  635. break;
  636. case 'color':
  637. $value = isset( $this->options[ $field_name ] ) ? $this->options[ $field_name ] : '';
  638. echo '<div class="sabox-colorpicker">';
  639. echo '<input id="' . esc_attr( $field_name ) . '" class="saboxfield sabox-color" name="' . esc_attr( $name ) . '" value="' . esc_attr( $value ) . '">';
  640. echo '</div>';
  641. break;
  642. case 'multiplecheckbox':
  643. echo '<div class="sabox-multicheckbox">';
  644. if ( ! isset( $field['choices'] ) && isset( $field['handle'] ) && is_array( $field['handle'] ) ) {
  645. if ( class_exists( $field['handle'][0] ) ) {
  646. $class = $field['handle'][0];
  647. $method = $field['handle'][1];
  648. $field['choices'] = $class::$method();
  649. }
  650. }
  651. if ( ! isset( $field['default'] ) ) {
  652. $field['default'] = array_keys( $field['choices'] );
  653. }
  654. $values = isset( $this->options[ $field_name ] ) ? $this->options[ $field_name ] : $field['default'];
  655. foreach ( $field['choices'] as $key => $choice ) {
  656. echo '<div>';
  657. echo '<input id="' . $key . '-' . $field_name . '" type="checkbox" value="' . $key . '" ' . checked( 1, in_array( $key, $values ), false ) . ' name="' . esc_attr( $name ) . '[]"><label for="' . $key . '-' . $field_name . '" class="checkbox-label">' . $choice . '</label>';
  658. echo '</div>';
  659. }
  660. echo '</div>';
  661. break;
  662. case 'radio-group':
  663. echo '<div class="sabox-radio-group">';
  664. echo '<fieldset>';
  665. foreach ( $field['choices'] as $key => $choice ) {
  666. echo '<input type="radio" id="' . esc_attr( $field_name . '_' . $key ) . '" name="' . esc_attr( $name ) . '" class="saboxfield" ' . checked( $key, $this->options[ $field_name ], false ) . ' value="' . esc_attr( $key ) . '">';
  667. echo '<label for="' . esc_attr( $field_name . '_' . $key ) . '">' . esc_attr( $choice ) . '</label>';
  668. }
  669. echo '</fieldset>';
  670. echo '</div>';
  671. break;
  672. default:
  673. do_action( "sabox_field_{$field['type']}_output", $field_name, $field );
  674. break;
  675. }
  676. echo '</td>';
  677. echo '</tr>';
  678. }
  679. public function render_pro_page() {
  680. $features = array(
  681. 'slider-options' => array(
  682. 'label' => esc_html__( 'Typography control', 'saboxplugin' ),
  683. 'sub' => esc_html__( 'Control Simple Author Box\'s typography. ', 'saboxplugin' ),
  684. 'sab' => '<span class="dashicons dashicons-yes"></span>',
  685. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  686. ),
  687. 'woocommerce' => array(
  688. 'label' => esc_html__( 'Appearance control', 'saboxplugin' ),
  689. 'sub' => esc_html__( 'Manage the looks of your Author Box. Color controls, margins, paddings, pre-defined color layouts & more.', 'saboxplugin' ),
  690. 'sab' => '<span class="dashicons dashicons-yes"></span>',
  691. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  692. ),
  693. 'reorder-sections' => array(
  694. 'label' => esc_html__( 'Visible on desired post types', 'saboxplugin' ),
  695. 'sub' => esc_html__( 'Select the post types where you want the author box to show up.', 'saboxplugin' ),
  696. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  697. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  698. ),
  699. 'custom-colors' => array(
  700. 'label' => esc_html__( 'Author name link control', 'saboxplugin' ),
  701. 'sub' => esc_html__( 'Control how author name links behave. Open in new tab, add nofollow parameter.', 'saboxplugin' ),
  702. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  703. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  704. ),
  705. 'typography' => array(
  706. 'label' => esc_html__( 'Color controls', 'saboxplugin' ),
  707. 'sub' => esc_html__( 'Customize the look of your author box. Make it yours!', 'saboxplugin' ),
  708. 'sab' => '<span class="dashicons dashicons-yes"></span>',
  709. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  710. ),
  711. 'features' => array(
  712. 'label' => esc_html__( 'Pre-defined color schemes', 'saboxplugin' ),
  713. 'sub' => esc_html__( 'Easily change your author box\'s looks with one of the included professionally designed pre-defined color schemes.', 'saboxplugin' ),
  714. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  715. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  716. ),
  717. 'portfolio' => array(
  718. 'label' => esc_html__( 'Author title', 'saboxplugin' ),
  719. 'sub' => '',
  720. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  721. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  722. ),
  723. 'services' => array(
  724. 'label' => esc_html__( 'Guest authors', 'saboxplugin' ),
  725. 'sub' => esc_html__( 'Easily assign post to guest authors. Make blogging & contributing easier.', 'saboxplugin' ),
  726. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  727. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  728. ),
  729. 'team' => array(
  730. 'label' => esc_html__( 'Post co-authors', 'saboxplugin' ),
  731. 'sub' => esc_html__( 'Working on a bigger piece with more colleagues? Get everyone\'s name listed without an issue.', 'saboxplugin' ),
  732. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  733. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  734. ),
  735. 'testimonials' => array(
  736. 'label' => esc_html__( 'Popular authors widget', 'saboxplugin' ),
  737. 'sub' => esc_html__( 'Showcase your most popular authors. Give back to the people who contribute to your blog.', 'saboxplugin' ),
  738. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  739. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  740. ),
  741. 'clients' => array(
  742. 'label' => esc_html__( 'Authors widget', 'saboxplugin' ),
  743. 'sub' => '',
  744. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  745. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  746. ),
  747. 'dedicated-support' => array(
  748. 'label' => esc_html__( 'Dedicated Support Team', 'saboxplugin' ),
  749. 'sab' => '<span class="dashicons dashicons-yes"></span>',
  750. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  751. ),
  752. 'security-updates' => array(
  753. 'label' => esc_html__( 'Critical security updates ', 'saboxplugin' ),
  754. 'sab' => '<span class="dashicons dashicons-yes"></span>',
  755. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  756. ),
  757. 'featured-updates' => array(
  758. 'label' => esc_html__( 'Future feature updates ', 'saboxplugin' ),
  759. 'sab' => '<span class="dashicons dashicons-no-alt"></span>',
  760. 'sab-pro' => '<span class="dashicons dashicons-yes"></span></i>',
  761. ),
  762. );
  763. ?>
  764. <div class="wrap about-wrap simple-author-box-wrap">
  765. <h1><?php echo esc_html__( 'Why you should be upgrading', 'saboxplugin' ); ?></h1>
  766. <p class="about-text"><?php echo esc_html__( 'Introducing one of the best author box systems ever made for WordPress. Simple Author Box is an exquisite WordPress Author Box plugin perfectly fit for any needs. We\'ve outlined the PRO features below.', 'saboxplugin' ); ?></p>
  767. <div class="wp-badge"></div>
  768. <h2 class="nav-tab-wrapper wp-clearfix">
  769. <a href="<?php echo admin_url( 'admin.php?page=sab-upgrade' ); ?>"
  770. class="nav-tab nav-tab-active"><?php echo esc_html__( 'Comparison Table: Lite vs PRO', 'saboxplugin' ); ?></a>
  771. </h2>
  772. <div class="featured-section features">
  773. <table class="free-pro-table">
  774. <thead>
  775. <tr>
  776. <th></th>
  777. <th><?php _e( 'Free', 'saboxplugin' ); ?></th>
  778. <th><?php _e( 'PRO', 'saboxplugin' ); ?></th>
  779. </tr>
  780. </thead>
  781. <tbody>
  782. <?php foreach ( $features as $feature ) : ?>
  783. <tr>
  784. <td class="feature">
  785. <h3><?php echo $feature['label']; ?></h3>
  786. <?php if ( isset( $feature['sub'] ) ) : ?>
  787. <p><?php echo $feature['sub']; ?></p>
  788. <?php endif ?>
  789. </td>
  790. <td class="sab-feature">
  791. <?php echo $feature['sab']; ?>
  792. </td>
  793. <td class="sab-pro-feature">
  794. <?php echo $feature['sab-pro']; ?>
  795. </td>
  796. </tr>
  797. <?php endforeach; ?>
  798. <tr>
  799. <td></td>
  800. <td colspan="2" class="text-right">
  801. <a href="//www.machothemes.com/plugin/simple-author-box-pro?utm_source=sab&utm_medium=about-page&utm_campaign=upsell"
  802. target="_blank" class="button button-primary button-hero">
  803. <span class="dashicons dashicons-cart"></span>
  804. <?php _e( 'Get The Pro Version Now!', 'saboxplugin' ); ?>
  805. </a></td>
  806. </tr>
  807. </tbody>
  808. </table>
  809. </div>
  810. </div>
  811. <?php
  812. }
  813. }