Commit c6e4fdd5 authored by Simonas's avatar Simonas

Merge branch 'contact-form' into dev

parents 77e1b17f 6547bc10
...@@ -64,6 +64,11 @@ ERROR: for mysql Cannot start service mysql: error while creating mount source ...@@ -64,6 +64,11 @@ ERROR: for mysql Cannot start service mysql: error while creating mount source
### Solution ### Solution
Restart docker (sometimes PC restart may be required) Restart docker (sometimes PC restart may be required)
### Error
Can't share C drive
### Solution
- https://tomssl.com/2018/01/11/sharing-your-c-drive-with-docker-for-windows-when-using-azure-active-directory-azuread-aad/
## Other (Commands) ## Other (Commands)
- docker-compose up -d - docker-compose up -d
...@@ -103,7 +108,7 @@ Restart docker (sometimes PC restart may be required) ...@@ -103,7 +108,7 @@ Restart docker (sometimes PC restart may be required)
- docker load --input ourdemo.tar - docker load --input ourdemo.tar
- docker build -t biuro/web:0.0.7 . - docker build -t biuro/web:0.0.8 .
- docker login --username=biuro --password=9Ndtjd2vKsLvGuFOeFq1KdJs - docker login --username=biuro --password=9Ndtjd2vKsLvGuFOeFq1KdJs
- sudo docker login --username=biuro --password=9Ndtjd2vKsLvGuFOeFq1KdJs - sudo docker login --username=biuro --password=9Ndtjd2vKsLvGuFOeFq1KdJs
- docker push biuro/web:0.0.7 - docker push biuro/web:0.0.7
...@@ -112,10 +117,11 @@ Restart docker (sometimes PC restart may be required) ...@@ -112,10 +117,11 @@ Restart docker (sometimes PC restart may be required)
### DB preview ### DB preview
- `docker exec -it dev-biuro-nginx sh`
- `docker exec -it dev-biuro-wordpress bash` - `docker exec -it dev-biuro-wordpress bash`
- `docker exec -it dev-biuro-mysql bash` - `docker exec -it dev-biuro-mysql bash`
- `mysql -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8` - `mysql -uroot -p'q@z!z29AO5rpzMjsDhjnFKyF' --default-character-set=utf8`
- `use wordpress;` - `use dev_biuro;`
- `show tables;` - `show tables;`
- `use information_schema;` - `use information_schema;`
......
...@@ -26,6 +26,7 @@ services: ...@@ -26,6 +26,7 @@ services:
- "front" - "front"
- "back" - "back"
volumes: volumes:
- ./nginx/.htpasswd:/etc/nginx/.htpasswd
- ./nginx/php.ini:/usr/local/etc/php/conf.d/php.ini - ./nginx/php.ini:/usr/local/etc/php/conf.d/php.ini
- ./wp-content/plugins/biuro-contacts:/var/www/html/wp-content/plugins/biuro-contacts - ./wp-content/plugins/biuro-contacts:/var/www/html/wp-content/plugins/biuro-contacts
...@@ -75,6 +76,7 @@ services: ...@@ -75,6 +76,7 @@ services:
- '80:80' - '80:80'
- '443:443' - '443:443'
volumes: volumes:
- ./nginx/.htpasswd:/etc/nginx/.htpasswd
- ./nginx/conf.d:/etc/nginx/conf.d - ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/h5bp:/etc/nginx/h5bp - ./nginx/h5bp:/etc/nginx/h5bp
- ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./nginx/nginx.conf:/etc/nginx/nginx.conf
...@@ -136,8 +138,39 @@ services: ...@@ -136,8 +138,39 @@ services:
- ./wordpress:/var/www/html - ./wordpress:/var/www/html
- './wp-init.sh:/usr/local/bin/wp-init.sh' - './wp-init.sh:/usr/local/bin/wp-init.sh'
command: # command:
- wp-init.sh # - wp-init.sh
command: >
/bin/sh -c '
sleep 45;
echo "WP CLI init";
wp core update --force;
wp core update-db --network;
wp option update permalink_structure "/%postname%/" --skip-themes --skip-plugins;
wp option update timezone_string "Manual Offsets/UTC+2";
wp option update date_format "Y-m-d";
wp option update time_format "H:i";
wp plugin install permalink-manager --force --activate-network;
wp plugin install pods --activate-network;
wp plugin install polylang --activate-network;
wp plugin install wordpress-seo --activate-network;
wp plugin update --all;
wp plugin activate akismet --network;
wp plugin activate biuro-contacts --network;
wp plugin activate biuro-feedbacks --network;
wp plugin activate biuro-html --network;
wp plugin activate biuro-sections --network;
wp plugin activate biuro-services --network;
wp plugin activate biuro-values --network;
wp plugin activate cookies-warning --network;
wp plugin activate data-controller --network;
wp theme update --all;
wp theme activate biuro;
wp language core update;
wp language theme update --all;
wp language plugin update --all;
echo "WP CLI done. Ready to use.";
'
networks: networks:
front: front:
......
biuro_wp_api:$apr1$vvI07kKw$MysnayQWamZReKludVojG.
...@@ -15,6 +15,15 @@ index index.php; ...@@ -15,6 +15,15 @@ index index.php;
location / { location / {
try_files $uri $uri/ /index.php?$args; try_files $uri $uri/ /index.php?$args;
# auth_basic "Restricted Content";
# auth_basic_user_file /etc/nginx/.htpasswd;
}
location /wp-json/api/v1/contacts {
try_files $uri $uri/ /index.php?$args;
auth_basic "Basic auth";
auth_basic_user_file /etc/nginx/.htpasswd;
# auth_basic_user_file /var/www/html/.htpasswd;
} }
location ~ \.php$ { location ~ \.php$ {
......
...@@ -100,4 +100,77 @@ class Biuro_Contacts_Admin { ...@@ -100,4 +100,77 @@ class Biuro_Contacts_Admin {
} }
// date DEFAULT '0000-00-00 00:00:00',
// name tinytext,
// surname tinytext,
// email varchar(128) DEFAULT '',
// phone varchar(128) DEFAULT '',
// city varchar(255) DEFAULT '',
// comment longtext DEFAULT '',
// cv text DEFAULT '',
public function get_rows_from_db_as_associative_array() {
global $wpdb;
$sql = "SELECT * FROM `" . $wpdb->prefix . "biuro_employees` ORDER BY id DESC";
return $wpdb->get_results( $sql, ARRAY_A );
}
public function insert_row_to_db() {
global $wpdb;
$table = $wpdb->prefix . 'biuro_employees';
$data = array(
'db_field_tinytext' => 'SOME TEXT',
'db_field_datetime' => date( 'Y-m-d H:i:s' ),
'db_field_varchar' => 'SOME OTHER TEXT',
'db_field_mediumint' => 123,
'db_field_text' => 'LONGER TEXT',
);
$format = array( '%s','%s', '%s', '%d', '%s' );
$wpdb->insert( $table, $data, $format );
return $wpdb->insert_id;
}
public function update_row_in_db() {
global $wpdb;
$table = $wpdb->prefix . 'biuro_employees';
$data = array(
'db_field_tinytext' => 'SOME TEXT',
'db_field_datetime' => date( 'Y-m-d H:i:s' ),
'db_field_varchar' => 'SOME OTHER TEXT',
'db_field_mediumint' => 123,
'db_field_text' => 'LONGER TEXT',
);
$format = array( '%s','%s', '%s', '%d', '%s' );
$where = array(
'ID' => 1
);
$where_format = array(
'%d'
);
return $wpdb->insert( $table, $data, $where, $format, $where_format );
}
public function delete_row_from_db() {
global $wpdb;
$table = $wpdb->prefix . 'biuro_employees';
$where = array(
'ID' => 1
);
$where_format = array(
'%d'
);
return $wpdb->delete( $table, $where, $where_format );
}
public function use_prepare_db_query() {
global $wpdb;
$sql = "UPDATE $wpdb->posts SET post_parent = %d WHERE ID = %d AND post_status = %s";
return $wpdb->query( $wpdb->prepare( $sql, 7, 15, 'static' ) );
}
} }
...@@ -30,7 +30,56 @@ class Biuro_Contacts_Activator { ...@@ -30,7 +30,56 @@ class Biuro_Contacts_Activator {
* @since 1.0.0 * @since 1.0.0
*/ */
public static function activate() { public static function activate() {
global $wpdb;
if ( is_multisite() ) {
// Get all blogs in the network and activate plugin on each one
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
self::create_db_employees();
restore_current_blog();
}
} else {
// create_table();
self::create_db_employees();
}
} }
public static function create_db_employees() {
global $wpdb;
$table_name = $wpdb->prefix . "biuro_employees";
$plugin_name_db_version = get_option( 'biuro-contacts_db_version', '1.0' );
if( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ||
version_compare( $version, '1.0' ) < 0 ) {
$charset_collate = $wpdb->get_charset_collate();
$sql[] = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
created datetime DEFAULT '0000-00-00 00:00:00',
name tinytext,
surname tinytext,
email varchar(128) DEFAULT '',
phone varchar(128) DEFAULT '',
city varchar(255) DEFAULT '',
comment longtext DEFAULT '',
cv text DEFAULT '',
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
/**
* It seems IF NOT EXISTS isn't needed if you're using dbDelta - if the table already exists it'll
* compare the schema and update it instead of overwriting the whole table.
*
* @link https://code.tutsplus.com/tutorials/custom-database-tables-maintaining-the-database--wp-28455
*/
dbDelta( $sql );
add_option( 'biuro-contacts_db_version', $plugin_name_db_version );
}
}
} }
...@@ -41,6 +41,15 @@ class Biuro_Contacts_Loader { ...@@ -41,6 +41,15 @@ class Biuro_Contacts_Loader {
*/ */
protected $filters; protected $filters;
/**
* The array of shortcodes registered with WordPress.
*
* @since 1.0.0
* @access protected
* @var array $shortcodes The shortcodes registered with WordPress to fire when the plugin loads.
*/
protected $shortcodes;
/** /**
* Initialize the collections used to maintain the actions and filters. * Initialize the collections used to maintain the actions and filters.
* *
...@@ -50,6 +59,7 @@ class Biuro_Contacts_Loader { ...@@ -50,6 +59,7 @@ class Biuro_Contacts_Loader {
$this->actions = array(); $this->actions = array();
$this->filters = array(); $this->filters = array();
$this->shortcodes = array();
} }
...@@ -81,6 +91,18 @@ class Biuro_Contacts_Loader { ...@@ -81,6 +91,18 @@ class Biuro_Contacts_Loader {
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
} }
/**
* Add a new shortcode to the collection to be registered with WordPress
*
* @since 1.0.0
* @param string $tag The name of the new shortcode.
* @param object $component A reference to the instance of the object on which the shortcode is defined.
* @param string $callback The name of the function that defines the shortcode.
*/
public function add_shortcode( $tag, $component, $callback, $priority = 10, $accepted_args = 2 ) {
$this->shortcodes = $this->add( $this->shortcodes, $tag, $component, $callback, $priority, $accepted_args );
}
/** /**
* A utility function that is used to register the actions and hooks into a single * A utility function that is used to register the actions and hooks into a single
* collection. * collection.
...@@ -124,6 +146,9 @@ class Biuro_Contacts_Loader { ...@@ -124,6 +146,9 @@ class Biuro_Contacts_Loader {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
} }
foreach ( $this->shortcodes as $hook ) {
add_shortcode( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
} }
} }
...@@ -156,7 +156,6 @@ class Biuro_Contacts { ...@@ -156,7 +156,6 @@ class Biuro_Contacts {
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
} }
/** /**
...@@ -173,12 +172,30 @@ class Biuro_Contacts { ...@@ -173,12 +172,30 @@ class Biuro_Contacts {
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
$this->loader->add_action( 'init', $plugin_public, 'register_shortcodes' );
$this->loader->add_action('admin_post_nopriv_employees_quick', $plugin_public, 'employeesQuickSubmit'); $this->loader->add_action('admin_post_employees_quick_post', $plugin_public, 'employees_quick_post');
$this->loader->add_action('admin_post_employees_quick', $plugin_public, 'employeesQuickSubmit'); $this->loader->add_action('admin_post_nopriv_employees_quick_post', $plugin_public, 'employees_quick_post');
$this->loader->add_action('admin_post_nopriv_employers_quick', $plugin_public, 'employersQuickSubmit'); $this->loader->add_action('admin_post_employers_quick_post', $plugin_public, 'employers_quick_post');
$this->loader->add_action('admin_post_employers_quick', $plugin_public, 'employersQuickSubmit'); $this->loader->add_action('admin_post_nopriv_employers_quick_post', $plugin_public, 'employers_quick_post');
// $this->loader->add_action( 'init', $plugin_public, 'register_shortcodes' );
/**
* Register shortcode via loader
*
* Use: [short-code-name args]
*
* @link https://github.com/DevinVinson/WordPress-Plugin-Boilerplate/issues/262
*/
$this->loader->add_shortcode( "biuro-contacts--employees-quick", $plugin_public, "employees_quick_form", $priority = 10, $accepted_args = 2 );
$this->loader->add_shortcode( "biuro-contacts--employers-quick", $plugin_public, "employers_quick_form", $priority = 10, $accepted_args = 2 );
// add_shortcode( 'biuro-contacts--employees-quick', array( $this, 'employees_quick_form' ) );
// add_shortcode( 'biuro-contacts--employers-quick', array( $this, 'employers_quick_form' ) );
// add_shortcode( 'biuro-contacts--employees', array( $this, 'employees_form' ) );
// add_shortcode( 'biuro-contacts--employers', array( $this, 'employers_form' ) );
// add_shortcode( 'biuro-contacts--position', array( $this, 'position_form' ) );
} }
/** /**
......
...@@ -11,42 +11,64 @@ ...@@ -11,42 +11,64 @@
* @package Biuro_Contacts * @package Biuro_Contacts
* @subpackage Biuro_Contacts/public/partials * @subpackage Biuro_Contacts/public/partials
*/ */
/**
* @link https://codex.wordpress.org/Creating_Options_Pages
* @link https://www.smashingmagazine.com/2016/04/three-approaches-to-adding-configurable-fields-to-your-plugin/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) die;
?> ?>
<form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" enctype="multipart/form-data" class="c-form"> <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" enctype="multipart/form-data" class="c-form">
<?php
$nameValue = get_transient( 'employees-quick--name-value' );
$nameStatus = get_transient( 'employees-quick--name-status' );
$nameMessage = get_transient( 'employees-quick--name-message' );
?>
<div class="c-form--row"> <div class="c-form--row">
<label class="c-form--label" for="form-name">Name, Surname*</label> <label class="c-form--label" for="form-name">Name, Surname*</label>
<div class="c-form--input-wrap"> <div class="c-form--input-wrap">
<input type="text" class="c-form--input <?php if ($response) { echo 'c-form--input--error'; } ?>" id="form-name" name="name" value=""> <input type="text" class="c-form--input <?php if ($nameStatus) { echo "c-form--input--$nameStatus"; } ?>" id="form-name" name="name" value="<?php echo $nameValue; ?>">
</div> </div>
<?php if ($response): ?> <?php if ($nameMessage): ?>
<div class="c-form--validation-error"> <div class="c-form--validation-<?php echo $nameStatus; ?>">
Name and Surname is required <?php echo $nameMessage; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div><!-- .c-form--row --> </div><!-- .c-form--row -->
<?php
$phoneValue = get_transient( 'employees-quick--phone-value' );
$phoneStatus = get_transient( 'employees-quick--phone-status' );
$phoneMessage = get_transient( 'employees-quick--phone-message' );
?>
<div class="c-form--row"> <div class="c-form--row">
<label class="c-form--label" for="form-phone">Phone no.*</label> <label class="c-form--label" for="form-phone">Phone no.*</label>
<div class="c-form--input-wrap"> <div class="c-form--input-wrap">
<input type="tel" class="c-form--input <?php if ($response) { echo 'c-form--input--error'; } ?>" id="form-phone" name="phone" value=""> <input type="tel" class="c-form--input <?php if ($phoneStatus) { echo "c-form--input--$phoneStatus"; } ?>" id="form-phone" name="phone" value="<?php echo $phoneValue; ?>">
</div> </div>
<?php if ($response): ?> <?php if ($phoneMessage): ?>
<div class="c-form--validation-error"> <div class="c-form--validation-<?php echo $phoneStatus; ?>">
Phone number is required <?php echo $phoneMessage; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div><!-- .c-form--row --> </div><!-- .c-form--row -->
<?php
$emailValue = get_transient( 'employees-quick--email-value' );
$emailStatus = get_transient( 'employees-quick--email-status' );
$emailMessage = get_transient( 'employees-quick--email-message' );
?>
<div class="c-form--row"> <div class="c-form--row">
<label class="c-form--label" for="form-email">Email address*</label> <label class="c-form--label" for="form-email">Email address*</label>
<div class="c-form--input-wrap"> <div class="c-form--input-wrap">
<input type="email" class="c-form--input <?php if ($response) { echo 'c-form--input--error'; } ?>" id="form-email" name="email" value=""> <input type="email" class="c-form--input <?php if ($emailStatus) { echo "c-form--input--$emailStatus"; } ?>" id="form-email" name="email" value="<?php echo $emailValue; ?>">
</div> </div>
<?php if ($response): ?> <?php if ($emailMessage): ?>
<div class="c-form--validation-error"> <div class="c-form--validation-<?php echo $emailStatus; ?>">
Email address is required <?php echo $emailMessage; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div><!-- .c-form--row --> </div><!-- .c-form--row -->
...@@ -57,18 +79,24 @@ ...@@ -57,18 +79,24 @@
</div> </div>
</div><!-- .c-form--row --> </div><!-- .c-form--row -->
<?php
$agreeValue = get_transient( 'employees-quick--agree-value' );
$agreeStatus = get_transient( 'employees-quick--agree-status' );
$agreeMessage = get_transient( 'employees-quick--agree-message' );
?>
<div class="c-form--row"> <div class="c-form--row">
<div class="c-form--checkbox-wrap"> <div class="c-form--checkbox-wrap">
<input id="form-agree" type="checkbox" class="c-form--checkbox <?php if ($response) { echo 'c-form--checkbox--error'; } ?>" name="agree" value="1"> <input id="form-agree" type="checkbox" class="c-form--checkbox <?php if ($agreeStatus) { echo "c-form--checkbox--$agreeStatus"; } ?>" name="agree" value="1" <?php if ($agreeValue): ?> checked="checked"<?php endif; ?>>
<label class="c-form--label-checkbox" for="form-agree">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem possimus, delectus unde enim dolores doloribus, recusandae a veritatis ducimus repudiandae iste eos voluptatum architecto mollitia?</label> <label class="c-form--label-checkbox" for="form-agree">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem possimus, delectus unde enim dolores doloribus, recusandae a veritatis ducimus repudiandae iste eos voluptatum architecto mollitia?</label>
</div> </div>
<?php if ($response): ?> <?php if ($agreeMessage): ?>
<div class="c-form--validation-error"> <div class="c-form--validation-<?php echo $agreeStatus; ?>">
You have to agree with conditions <?php echo $agreeMessage; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div><!-- .c-form--row --> </div><!-- .c-form--row -->
<input type="hidden" name="action" value="employees_quick"> <input type="hidden" name="action" value="employees_quick_post">
<?php wp_nonce_field('employees_quick_nonce', 'employees_quick_nonce'); ?> <?php wp_nonce_field('employees_quick_post_nonce'); ?>
</form> </form>
...@@ -11,6 +11,15 @@ ...@@ -11,6 +11,15 @@
* @package Biuro_Contacts * @package Biuro_Contacts
* @subpackage Biuro_Contacts/public/partials * @subpackage Biuro_Contacts/public/partials
*/ */
/**
* @link https://codex.wordpress.org/Creating_Options_Pages
* @link https://www.smashingmagazine.com/2016/04/three-approaches-to-adding-configurable-fields-to-your-plugin/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) die;
// Generate a custom nonce value.
$_nonce = wp_create_nonce( 'my_post_form_nonce' );
?> ?>
<form id="ContactFormEmployee_ContactFormEmployee" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post" enctype="multipart/form-data" class="contact-form"> <form id="ContactFormEmployee_ContactFormEmployee" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post" enctype="multipart/form-data" class="contact-form">
......
...@@ -11,6 +11,15 @@ ...@@ -11,6 +11,15 @@
* @package Biuro_Contacts * @package Biuro_Contacts
* @subpackage Biuro_Contacts/public/partials * @subpackage Biuro_Contacts/public/partials
*/ */
/**
* @link https://codex.wordpress.org/Creating_Options_Pages
* @link https://www.smashingmagazine.com/2016/04/three-approaches-to-adding-configurable-fields-to-your-plugin/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) die;
// Generate a custom nonce value.
$_nonce = wp_create_nonce( 'my_post_form_nonce' );
?> ?>
<form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" enctype="multipart/form-data" class="c-form"> <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" enctype="multipart/form-data" class="c-form">
......
...@@ -11,6 +11,15 @@ ...@@ -11,6 +11,15 @@
* @package Biuro_Contacts * @package Biuro_Contacts
* @subpackage Biuro_Contacts/public/partials * @subpackage Biuro_Contacts/public/partials
*/ */
/**
* @link https://codex.wordpress.org/Creating_Options_Pages
* @link https://www.smashingmagazine.com/2016/04/three-approaches-to-adding-configurable-fields-to-your-plugin/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) die;
// Generate a custom nonce value.
$_nonce = wp_create_nonce( 'my_post_form_nonce' );
?> ?>
<form id="ContactForm_ContactForm" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post" enctype="application/x-www-form-urlencoded" class="contact-form"> <form id="ContactForm_ContactForm" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post" enctype="application/x-www-form-urlencoded" class="contact-form">
......
...@@ -11,6 +11,15 @@ ...@@ -11,6 +11,15 @@
* @package Biuro_Contacts * @package Biuro_Contacts
* @subpackage Biuro_Contacts/public/partials * @subpackage Biuro_Contacts/public/partials
*/ */
/**
* @link https://codex.wordpress.org/Creating_Options_Pages
* @link https://www.smashingmagazine.com/2016/04/three-approaches-to-adding-configurable-fields-to-your-plugin/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) die;
// Generate a custom nonce value.
$_nonce = wp_create_nonce( 'my_post_form_nonce' );
?> ?>
<form id="CVForm_CVForm" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post" enctype="multipart/form-data" class="contact-form"> <form id="CVForm_CVForm" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post" enctype="multipart/form-data" class="contact-form">
......
...@@ -5,5 +5,9 @@ ...@@ -5,5 +5,9 @@
/* critical:end */ /* critical:end */
.c-form--input--error { border: 1px solid #f90000; } .c-form--input--error { border: 1px solid #f90000; }
.c-form--input--success { border: 1px solid green; }
.c-form--input--warning { border: 1px solid orange; }
.c-form--validation-error { color: #f90000; margin-bottom: 10px;} .c-form--validation-error { color: #f90000; margin-bottom: 10px;}
.c-form--validation-success { color: green; margin-bottom: 10px;}
.c-form--validation-warning { color: orange; margin-bottom: 10px;}
This diff is collapsed.
This diff is collapsed.
...@@ -123,7 +123,7 @@ document.querySelectorAll('.js-job-action').forEach(function (node) { ...@@ -123,7 +123,7 @@ document.querySelectorAll('.js-job-action').forEach(function (node) {
}); });
</script> </script>
<script src="/wp-content/themes/biuro/js/main-a9a206ea.min.js" async></script> <script src="/wp-content/themes/biuro/js/main-19c9eea4.min.js" async></script>
<?php wp_footer(); ?> <?php wp_footer(); ?>
</body> </body>
</html> </html>
...@@ -10,7 +10,6 @@ function delog($str, $label = 'Label') { ...@@ -10,7 +10,6 @@ function delog($str, $label = 'Label') {
echo '<h1 style="white-space: nowrap;">' . $label . ': ' . $str . '</h1>'; echo '<h1 style="white-space: nowrap;">' . $label . ': ' . $str . '</h1>';
} }
function cc_mime_types($mimes) { function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml'; $mimes['svg'] = 'image/svg+xml';
return $mimes; return $mimes;
...@@ -412,6 +411,48 @@ add_action('init', 'df_disable_comments_admin_bar'); ...@@ -412,6 +411,48 @@ add_action('init', 'df_disable_comments_admin_bar');
// require_once 'includes/disable_discussion'; // require_once 'includes/disable_discussion';
function getContacts ( $request ) {
$res = array();
array_push($res, array(
'id' => 1,
'date' => '2019-03-15 19:05:44',
'name' => 'Vardenis',
'surname' => 'Pavardenis',
'phone' => '+37060000000',
'email' => 'email@example.com',
'city' => '',
'comment' => '',
'cv' => ''
) );
array_push($res, array(
'id' => 2,
'date' => '2019-04-01 08:08:17',
'name' => 'Jonas',
'surname' => 'Jonaitis Kazlauskaitis',
'phone' => '',
'email' => 'jonas@example.com',
'city' => 'Vilnius',
'comment' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est ducimus iusto modi a, iure. Provident.',
'cv' => '/path/to/000000000000000.pdf'
) );
array_push($res, array(
'id' => 3,
'date' => '2019-04-10 07:43:02',
'name' => 'Eglė',
'surname' => 'Pavardenytė',
'phone' => '',
'email' => 'egle@example.com',
'city' => 'Kaunas',
'comment' => '',
'cv' => ''
) );
return new WP_REST_Response( $res, 200 );
}
function getDivisions ( $request ) { function getDivisions ( $request ) {
$res = array(); $res = array();
$params = $request->get_params(); $params = $request->get_params();
...@@ -454,7 +495,7 @@ function getDivisions ( $request ) { ...@@ -454,7 +495,7 @@ function getDivisions ( $request ) {
add_action( 'rest_api_init', function () { add_action( 'rest_api_init', function () {
register_rest_route( 'biuro-api/v1', '/divisions', array( register_rest_route( 'api/v1', '/divisions', array(
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => 'getDivisions', 'callback' => 'getDivisions',
'args' => array( 'args' => array(
...@@ -466,4 +507,9 @@ add_action( 'rest_api_init', function () { ...@@ -466,4 +507,9 @@ add_action( 'rest_api_init', function () {
) )
)); ));
register_rest_route( 'api/v1', '/contacts', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'getContacts'
));
}); });
...@@ -33,14 +33,14 @@ define('cityID', $cityID); ...@@ -33,14 +33,14 @@ define('cityID', $cityID);
<style><?php include 'css/core-a25434ed1d.min.css'; ?></style> <style><?php include 'css/core-a25434ed1d.min.css'; ?></style>
<link rel="preload" href="/wp-content/themes/biuro/css/main-e48562fc43.min.css" as="style" onload="this.rel='stylesheet'"> <link rel="preload" href="/wp-content/themes/biuro/css/main-4233b63eb8.min.css" as="style" onload="this.rel='stylesheet'">
<link rel="preload" href="/wp-content/themes/biuro/fonts/pt_sans_narrow.woff2" as="font" type="font/woff2" crossorigin> <link rel="preload" href="/wp-content/themes/biuro/fonts/pt_sans_narrow.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/wp-content/themes/biuro/fonts/pt_sans_narrow_bold.woff2" as="font" type="font/woff2" crossorigin> <link rel="preload" href="/wp-content/themes/biuro/fonts/pt_sans_narrow_bold.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/wp-content/themes/biuro/fonts/bebas-neue.woff2" as="font" type="font/woff2" crossorigin> <link rel="preload" href="/wp-content/themes/biuro/fonts/bebas-neue.woff2" as="font" type="font/woff2" crossorigin>
<noscript> <noscript>
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main-e48562fc43.min.css"> <link rel="stylesheet" href="/wp-content/themes/biuro/css/main-4233b63eb8.min.css">
</noscript> </noscript>
<?php wp_head(); ?> <?php wp_head(); ?>
......
...@@ -46,7 +46,7 @@ if (module.hot) { ...@@ -46,7 +46,7 @@ if (module.hot) {
return; return;
} }
fetch('/wp-json/biuro-api/v1/divisions?lang=' + node.dataset.lang) fetch('/wp-json/api/v1/divisions?lang=' + node.dataset.lang)
.then((t) => t.json()) .then((t) => t.json())
.then((data) => { .then((data) => {
initDivisionsMap(node, data); initDivisionsMap(node, data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment