Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Our callback to create the contact form page.
- function gym_contact_create_form() {
- $form = array(
- 'post_title' => wp_strip_all_tags( 'Gym Contact Page' ),
- 'post_name' => 'gym-contact-form',
- 'post_status' => 'publish',
- 'post_author' => 1,
- 'post_type' => 'page',
- );
- // Check if page exists
- $page = get_page_by_path('gym-contact-form');
- if ($page == NULL) {
- // Create a page upon creation.
- wp_insert_post( $form );
- }
- }
- // Mock data
- function gym_contact_install_data() {
- global $wpdb;
- $table_name = $wpdb->prefix . 'contact';
- $test_name = 'Michael Williams';
- $test_email = 'mikew@monarchdigital.com';
- $test_phone = '(719)344-2118';
- $test_message = 'This is my test message. My heater needs repair.';
- $wpdb->insert(
- $table_name,
- array(
- 'name' => $test_name,
- 'email' => $test_email,
- 'phone' => $test_phone,
- 'message' => $test_message,
- 'time' => current_time( 'mysql' )
- )
- );
- }
- // Hook up our template file for the contact form - https://codex.wordpress.org/Plugin_API/Filter_Reference/page_template
- add_filter( 'page_template', 'gym_contact_form_template' );
- function gym_contact_form_template( $page_template ) {
- if ( is_page( 'Gym Contact Page' ) ) {
- $page_template = dirname( __FILE__ ) . '/includes/gym_contact_form.php';
- }
- return $page_template;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement