init_sections_register_fields

The Contact Form 7 Style init sections register fields class.

Defined (1)

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

/inc/editor_page.php  
  1. class init_sections_register_fields { 
  2. function init_sections_register_fields( ) { 
  3. add_filter( 'admin_init' , array( $this , 'register_new_fields' ) ); 
  4. function cf7style_render_checkbox( $option, $args, $description, $tulip ) { 
  5. $tulip = $tulip ? '<div class="cf7style-tooltip" title="more info"><i class="fa fa-question-circle" aria-hidden="true"></i><div class="cf7style-tooltip-content">'.$tulip.'<div/></div>' : ''; 
  6. return '<label><input type="checkbox" value="1" '.checked( 1, $option, false).' id="'.$args[0].'[' . $args[0] . ']" name="'.$args[0].'" />'.__( $description, 'contact-form-7-style' ).'</label>'.$tulip; 
  7. function cf7style_collection_structure( $args ) { 
  8. $html = ""; 
  9. $html .= '</tr>'; 
  10. /**$html .= '<tr><td colspan="2"><p>'.__( "Want to help make Contact Form 7 Style even more better? Allow Us to collect non-sensitive diagnostic data.", "contact-form-7-style" ).'</p><p>'.__( "We will only collect your website URL, WordPress version, Contact Form 7 Style plugin version and active status.", "contact-form-7-style" ).'</p></td></tr>';*/ 
  11. $html .= '<tr><td colspan="2">'; 
  12. $option = get_option( $args[0] ); 
  13. $html .= $this->cf7style_render_checkbox( $option, $args, 'Allow collecting data', '<p>'.__( "Want to help make Contact Form 7 Style even more better? Allow Us to collect non-sensitive diagnostic data.", "contact-form-7-style" ).'</p><p>'.__( "We will only collect your website URL, WordPress version, Contact Form 7 Style plugin version and active status.", "contact-form-7-style" ).'</p>' ); 
  14. $html .= '</td></tr><tr><td colspan="2">'; 
  15.  
  16. return $html; 
  17. function cf7style_templates_structure ( $args) { 
  18. $html = ""; 
  19. $html .= '</tr>'; 
  20. /**$html .= '<tr><td colspan="2"><p>'.__( "From here you will be able to import the Contact Form 7 Style predefined templates.", "contact-form-7-style" ).'</p></td></tr>'; 
  21. $html .= '<tr><td colspan="2"><p><small>'.__( "This works only if the predefined templates are Deleted Permanently (they don't appear in", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a> ).</small></p></td></tr>';*/ 
  22. $html .= '<tr><td colspan="2">'; 
  23. $option = get_option( $args[0] ); 
  24. if( $option == '1') { 
  25. update_option( 'cf7_style_add_categories', 0 ); 
  26. if( isset($_POST[ 'cf7styletracking' ]) ) { 
  27. update_option( 'cf7_style_no_temps', 'show_box' ); 
  28. $html .= $this->cf7style_render_checkbox( $option, $args, 'Install predefined templates', '<p>'.__( "From here you will be able to import the Contact Form 7 Style predefined templates.", "contact-form-7-style" ).'</p><p><small>'.__( "This works only if the predefined templates are Deleted Permanently (they don't appear in", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a> ).</small></p>' ); 
  29. $html .= '</td></tr><tr><td colspan="2">'; 
  30. return $html; 
  31.  
  32. function cf7style_tooltip_structure( $args ) { 
  33. $html = ""; 
  34. $html .= '</tr>'; 
  35. $html .= '<tr><td colspan="2">'; 
  36. $option = get_option( $args[0] ); 
  37. if( isset( $_POST[ 'cf7_style_form_tooltip' ] ) ) { 
  38. update_option( 'cf7_style_form_tooltip', '1' ); 
  39. $html .= $this->cf7style_render_checkbox( $option, $args, 'Show the frontend form edit button', '' ); 
  40. $html .= '</td></tr><tr><td colspan="2">'; 
  41. return $html; 
  42.  
  43. function cf7style_forcecss_structure( $args ) { 
  44. $html = ""; 
  45. $html .= '</tr>'; 
  46. $html .= '<tr><td colspan="2">'; 
  47. $option = get_option( $args[0] ); 
  48. if( isset( $_POST[ 'cf7_style_forcecss' ] ) ) { 
  49. update_option( 'cf7_style_forcecss', '1' ); 
  50. $html .= $this->cf7style_render_checkbox( $option, $args, 'Force CSS', '' ); 
  51. $html .= '</td></tr><tr><td colspan="2">'; 
  52. return $html; 
  53.  
  54. function register_new_fields() { 
  55. add_settings_section(  
  56. 'cf7styleeditor',  
  57. __('Global CSS', 'contact-form-7-style'),  
  58. array( $this, 'description' ),  
  59. 'cf7style-css-editor' 
  60. ); 
  61. add_settings_section(  
  62. 'cf7stylesettings',  
  63. __('Contact Form 7 Style Settings', 'contact-form-7-style'),  
  64. array( $this, 'settings_description' ),  
  65. 'cf7style-settings' 
  66. ); 
  67. $fields = array ( 
  68. 'cf7_style_manual_style' => 'CSS',  
  69. ); 
  70.  
  71. $set_fields = array ( 
  72. 'cf7_style_allow_tracking' => __('Data collection', 'contact-form-7-style'),  
  73. 'cf7_style_deleted' => __('Import predefined Contact Form 7 Style templates', 'contact-form-7-style'),  
  74. 'cf7_style_form_tooltip' => __( 'Display form edit tooltip on frontend?', 'contact-form-7-style' ),  
  75. 'cf7_style_forcecss' => __( 'Active theme overrides your form styling?', 'contact-form-7-style' ),  
  76. ); 
  77. foreach ( $set_fields as $field => $value ) { 
  78. add_settings_field( 
  79. $field,  
  80. $value,  
  81. array($this, 'setting_inputs'),  
  82. 'cf7style-settings',  
  83. 'cf7stylesettings',  
  84. array( $field )  
  85. );  
  86. register_setting( 'general', $field, 'esc_attr' ); 
  87.  
  88. foreach ( $fields as $field => $value ) { 
  89. add_settings_field( 
  90. $field,  
  91. $value,  
  92. array($this, 'text_inputs'),  
  93. 'cf7style-css-editor',  
  94. 'cf7styleeditor',  
  95. array( $field )  
  96. );  
  97. register_setting( 'general', $field, 'esc_attr' ); 
  98. }  
  99.  
  100. function setting_inputs( $args ) { 
  101.  
  102. if(isset( $_POST[ $args[0] ] )) { 
  103. update_option( $args[0], 1 ); 
  104. } else { 
  105. if(isset($_POST[ 'cf7styletracking' ])) { 
  106. update_option( $args[0], 0 ); 
  107. if( isset( $_POST['cf7_style_form_tooltip'] ) ) { 
  108. update_option( $args[0], 0 ); 
  109. }  
  110. switch($args[0]) { 
  111. case 'cf7_style_allow_tracking' :  
  112. echo $this->cf7style_collection_structure( $args ); 
  113. break; 
  114. case 'cf7_style_deleted': 
  115. echo $this->cf7style_templates_structure( $args ); 
  116. break; 
  117. case 'cf7_style_form_tooltip' : 
  118. echo $this->cf7style_tooltip_structure( $args ); 
  119. break; 
  120. case 'cf7_style_forcecss' : 
  121. echo $this->cf7style_forcecss_structure( $args ); 
  122. break; 
  123. function text_inputs( $args ) { 
  124. if ( isset( $_POST[ $args[0] ] ) ) { 
  125. update_option( $args[0], $_POST[$args[0]] ); 
  126. $option = stripslashes(get_option( $args[0] )); 
  127. if ( version_compare( phpversion() , '5.3', '>' ) ) { 
  128. require_once 'cssparser.php'; 
  129. $css = new CSSParser(); 
  130. echo "<div class='parser-message'>"; 
  131. $cssIndex = $css->ParseCSS($option); 
  132. echo "</div>"; 
  133. echo '<form method="POST" action="">'; 
  134. echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option. '</textarea>'; 
  135. submit_button( 'Save CSS', 'primary' ); 
  136. echo '</form>'; 
  137. function description() { 
  138. echo '<p>'.__('On this page You can add a custom CSS mark-up, especially rules which could not be loaded via the style customizer above.', 'contact-form-7-style').'</p>'; 
  139. function settings_description() {