cf7style_load_elements

The Contact Form 7 Style cf7style load elements function.

Description

cf7style_load_elements(); 

Usage

  1. if ( !function_exists( 'cf7style_load_elements' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7-style/cf7-style.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = cf7style_load_elements(); 
  7.  

Defined (1)

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

/cf7-style.php  
  1. function cf7style_load_elements() { 
  2.  
  3. $labels = array( 
  4. 'name' => _x( 'Contact Styles', 'Post Type General Name', 'contact-form-7-style' ),  
  5. 'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'contact-form-7-style' ),  
  6. 'menu_name' => __( 'Contact Style', 'contact-form-7-style' ),  
  7. 'parent_item_colon' => __( 'Parent Style:', 'contact-form-7-style' ),  
  8. 'all_items' => __( 'All Styles', 'contact-form-7-style' ),  
  9. 'view_item' => __( 'View Style', 'contact-form-7-style' ),  
  10. 'add_new_item' => __( 'Add New', 'contact-form-7-style' ),  
  11. 'add_new' => __( 'Add New', 'contact-form-7-style' ),  
  12. 'edit_item' => __( 'Edit Style', 'contact-form-7-style' ),  
  13. 'update_item' => __( 'Update Style', 'contact-form-7-style' ),  
  14. 'search_items' => __( 'Search Style', 'contact-form-7-style' ),  
  15. 'not_found' => __( 'Not found', 'contact-form-7-style' ),  
  16. 'not_found_in_trash' => __( 'Not found in Trash', 'contact-form-7-style' ) 
  17. ); 
  18. $args = array( 
  19. 'label' => __( 'cf7_style', 'contact-form-7-style' ),  
  20. 'description' => __( 'Add/remove contact style', 'contact-form-7-style' ),  
  21. 'labels' => $labels,  
  22. 'supports' => array( 'title' ),  
  23. 'hierarchical' => false,  
  24. 'taxonomies' => array('style_category'),  
  25. 'public' => true,  
  26. 'show_ui' => true,  
  27. 'show_in_menu' => true,  
  28. 'show_in_nav_menus' => false,  
  29. 'show_in_admin_bar' => false,  
  30. 'menu_icon' => "dashicons-twitter",  
  31. 'menu_position' => 28.555555,  
  32. 'can_export' => true,  
  33. 'has_archive' => false,  
  34. 'exclude_from_search' => true,  
  35. 'publicly_queryable' => false,  
  36. 'capability_type' => 'page' 
  37. ); 
  38. /**register custom post type CF7_STYLE*/ 
  39. register_post_type( 'cf7_style', $args ); 
  40.  
  41. $labels = array( 
  42. 'name' => _x( 'Categories', 'Taxonomy General Name', 'contact-form-7-style' ),  
  43. 'singular_name' => _x( 'Categories', 'Taxonomy Singular Name', 'contact-form-7-style' ),  
  44. 'menu_name' => __( 'Categories', 'contact-form-7-style' ),  
  45. 'all_items' => __( 'All Categories', 'contact-form-7-style' ),  
  46. 'parent_item' => __( 'Parent Categories', 'contact-form-7-style' ),  
  47. 'parent_item_colon' => __( 'Parent Categories:', 'contact-form-7-style' ),  
  48. 'new_item_name' => __( 'New Categories Name', 'contact-form-7-style' ),  
  49. 'add_new_item' => __( 'Add New Categories', 'contact-form-7-style' ),  
  50. 'edit_item' => __( 'Edit Categories', 'contact-form-7-style' ),  
  51. 'update_item' => __( 'Update Categories', 'contact-form-7-style' ),  
  52. 'separate_items_with_commas' => __( 'Separate Categories with commas', 'contact-form-7-style' ),  
  53. 'search_items' => __( 'Search Categories', 'contact-form-7-style' ),  
  54. 'add_or_remove_items' => __( 'Add or remove Categories', 'contact-form-7-style' ),  
  55. 'choose_from_most_used' => __( 'Choose from the most used Categories', 'contact-form-7-style' ),  
  56. 'not_found' => __( 'Not Found', 'contact-form-7-style' ),  
  57. ); 
  58. $args = array( 
  59. 'labels' => $labels,  
  60. 'hierarchical' => true,  
  61. 'public' => true,  
  62. 'show_ui' => false,  
  63. 'show_admin_column' => true,  
  64. 'show_in_nav_menus' => false,  
  65. 'show_tagcloud' => true,  
  66. ); 
  67. //register tax 
  68. register_taxonomy( 'style_category', array( 'cf7_style' ), $args ); 
  69.  
  70. foreach ( get_predefined_cf7_style_template_data() as $style ) { 
  71. cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] ); 
  72. if( get_option( 'cf7_style_add_categories', 0 ) == 0 ) { 
  73. $cf7_style_args = array( 
  74. 'post_type' => 'cf7_style',  
  75. 'posts_per_page' => '-1' 
  76. ); 
  77.  
  78. $cf7_style_query = new WP_Query( $cf7_style_args ); 
  79. if ( $cf7_style_query->have_posts() ) { 
  80. while ( $cf7_style_query->have_posts() ) { 
  81. $cf7_style_query->the_post(); 
  82. $temp_title = get_the_title(); 
  83. $temp_ID = get_the_ID(); 
  84.  
  85. foreach ( get_predefined_cf7_style_template_data() as $style ) { 
  86. if( $temp_title == wptexturize( $style[ 'title' ] ) ) { 
  87. wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' ); 
  88. wp_reset_postdata(); 
  89. update_option( 'cf7_style_add_categories', 1 ); 
  90. $cf7_style_update_saved = get_option( 'cf7_style_update_saved' ); 
  91. if( $cf7_style_update_saved == "yes" ) { 
  92. $cf7_style_args = array( 
  93. 'post_type' => 'cf7_style',  
  94. 'style_category' => 'custom-style',  
  95. 'posts_per_page' => '-1' 
  96. ); 
  97. $cf7s_manual_old_style = ""; 
  98. $new_settings = array(); 
  99. $cf7_style_query = new WP_Query( $cf7_style_args ); 
  100. if ( $cf7_style_query->have_posts() ) { 
  101. while ( $cf7_style_query->have_posts() ) { 
  102. $cf7_style_query->the_post(); 
  103. $cur_style_id = get_the_ID(); 
  104. $cur_manual_style = get_post_meta( $cur_style_id, 'cf7_style_manual_style', true ); 
  105. $cur_custom_styles = maybe_unserialize( get_post_meta( $cur_style_id, 'cf7_style_custom_styles', true )); 
  106. if($cur_manual_style) { 
  107. $cf7s_manual_old_style .= $cur_manual_style; 
  108. update_post_meta( $cur_style_id, 'cf7_style_manual_style', '' ); 
  109. if($cur_custom_styles) { 
  110. $cf7s_custom_old_settings = $cur_custom_styles; 
  111. require_once( 'cf7-style-match-old.php' ); 
  112. $new_settings = get_new_styler_data( $cf7s_custom_old_settings ); 
  113. update_post_meta( $cur_style_id, 'cf7_style_manual_styles', ''); 
  114. update_post_meta( $cur_style_id, 'cf7_style_custom_styles', ''); 
  115. update_post_meta( $cur_style_id, 'cf7_style_custom_styler', $new_settings, ""); 
  116. wp_reset_postdata(); 
  117. if($cf7s_manual_old_style) { 
  118. update_option( 'cf7_style_manual_style', $cf7s_manual_old_style ); 
  119. update_option( 'cf7_style_update_saved', 'no' ); 
  120. require_once( 'cf7-style-meta-box.php' ); 
  121. if ( ! is_admin() ) {