*/ class Advisr_Toolbox_Public { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->advisr_toolbox_options = get_option($this->plugin_name); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Advisr_Toolbox_Loader as all of the hooks are defined * in that particular class. * * The Advisr_Toolbox_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/advisr-toolbox-public.css', array(), $this->version, 'all' ); wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/bootstrap.min.css', array(), $this->version, 'all' ); wp_enqueue_style( 'advisr-bootstrap', plugin_dir_url( __FILE__ ) . 'css/vendor/bootstrap/bootstrap-custom.css', array(), $this->version, 'all' ); // wp_enqueue_style( 'custombox', plugin_dir_url( __FILE__ ) . 'css/vendor/custombox/custombox.min.css', array(), $this->version, 'all' ); wp_enqueue_style( 'fontawesome', plugin_dir_url( __FILE__ ) . 'css/vendor/fontawesome/css/font-awesome.min.css', array(), $this->version, 'all' ); wp_enqueue_style( 'font', plugin_dir_url( __FILE__ ) . 'css/fonts/Proxima-Nova/stylesheet.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Advisr_Toolbox_Loader as all of the hooks are defined * in that particular class. * * The Advisr_Toolbox_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ // Register the Advisr Toolbox script file for enqueueing in function team_pages_member_post_type() wp_register_script( 'advisr-reviews', plugin_dir_url( __FILE__ ) . 'js/advisr-team-page.js', array(), 1.0, true ); wp_enqueue_script( 'advisr-bootstrap', plugin_dir_url( __FILE__ ) . 'js/vendor/bootstrap/bootstrap.min.js', array( 'jquery' ), $this->version, false ); wp_enqueue_script( 'custombox', plugin_dir_url( __FILE__ ) . 'js/vendor/custombox/dist/custombox.min.js', array( 'jquery' ), $this->version, false ); wp_enqueue_script( 'hs-core', plugin_dir_url( __FILE__ ) . 'js/vendor/hs.core.js', array( 'jquery' ), $this->version, false ); wp_enqueue_script( 'hs-modal-window', plugin_dir_url( __FILE__ ) . 'js/vendor/hs.modal-window.js', array( 'jquery' ), $this->version, false ); } /** * Shortcode to display team page list * * Since everything within the plugin is registered via hooks, * then kicking off the plugin from this point in the file does * not affect the page life cycle. * * @since 1.0.0 */ public function team_pages_member_post_type() { $args = array( 'post_type' => 'advisr-team-member', 'posts_per_page' => '-1', 'publish_status' => 'published', 'orderby' => 'meta_value_num', 'meta_key' => 'order', 'order' => 'ASC' ); $query = new WP_Query($args); $team_members = []; $result = ''; if($query->have_posts()) : while($query->have_posts()) : $query->the_post() ; array_push($team_members, array( 'name' => get_the_title(), 'description' => get_the_content(), // @TODO camelcase fields 'avatar_url' => get_the_post_thumbnail_url(get_the_ID(), 'medium'), 'role' => get_post_meta(get_the_ID(), 'role', true), 'mobile' => get_post_meta(get_the_ID(), 'mobile', true), 'telephone' => get_post_meta(get_the_ID(), 'telephone', true), 'email' => get_post_meta(get_the_ID(), 'email', true), 'order' => get_post_meta(get_the_ID(), 'order', true) )); endwhile; wp_reset_postdata(); endif; $result .= ''; $script_params = array( 'teamMembers' => $team_members, 'apikey' => $this->advisr_toolbox_options['apikey'], 'advisrBrokersConfig' => $this->advisr_toolbox_options['advisr-brokers-config'] ); // pass results from WP_Query to js wp_localize_script( 'advisr-reviews', 'scriptParams', $script_params ); wp_enqueue_script( 'advisr-reviews' ); return $result; } public function advisr_toolbox_register_shortcodes() { $plugin_public = new Advisr_Toolbox_Public( $this->get_plugin_name(), $this->get_version() ); add_shortcode( 'advisr-team-page', array($plugin_public, 'team_pages_member_post_type' )); } function custom_footer_ajex() { ?> get_plugin_name(), $this->get_version() ); add_action('wp_head',array($plugin_public, 'custom_footer_ajex' )); } function save_review_custom_pop() { $advisr_toolbox= get_option('advisr-toolbox'); $apikey=$advisr_toolbox['apikey']; //print_r($_POST[user_name]); $rating=$_POST['rating']; if (empty($rating)) { $rating=1; } $fields = array( 'reviewee_id' => $_POST['reviewee_id'], 'rating' => $rating, 'fullName' => $_POST['user_name'], 'email' => $_POST['email_user'], 'comment' => $_POST['comment_user'] ); $fields = json_encode($fields); //print_r($field); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://advisr.com.au/api/v2/reviews/submit", // CURLOPT_URL => "https://advisr.advisrdev.com.au/api/v2/reviews/submit", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", ///curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); CURLOPT_POSTFIELDS => $fields, CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "authorization: Bearer ".$apikey, ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { //= echo $response; } //print_r( $response); if(!empty($response)){ echo "Done"; } exit; } //add_action('wp_ajax_save_review_custom_pop', 'save_review_custom_pop'); //add_action('wp_ajax_nopriv_save_review_custom_pop', 'save_review_custom_pop'); public function advisr_toolbox_save_review_custom_pop() { $plugin_public = new Advisr_Toolbox_Public( $this->get_plugin_name(), $this->get_version() ); add_action('wp_ajax_save_review_custom_pop', array($plugin_public, 'save_review_custom_pop' )); add_action('wp_ajax_nopriv_save_review_custom_pop',array($plugin_public, 'save_review_custom_pop' )); add_action('wp_ajax_save_massage_drop_user_custom_pop', array($plugin_public, 'save_massage_drop_user_custom_pop' )); add_action('wp_ajax_nopriv_save_massage_drop_user_custom_pop',array($plugin_public, 'save_massage_drop_user_custom_pop' )); } function save_massage_drop_user_custom_pop(){ $advisr_toolbox= get_option('advisr-toolbox'); $apikey=$advisr_toolbox['apikey']; $fields = array( 'user_id' => $_POST['reviewee_id'], 'firstName' => $_POST['first_name'], 'lastName' => $_POST['last_name'], 'email' => $_POST['email_user'], 'mobile' => $_POST['phone_number'], 'message' => $_POST['comment_user'] ); $fields = json_encode($fields); //print_r($field); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://advisr.com.au/api/v2/leads/submit", // CURLOPT_URL => "https://advisr.advisrdev.com.au/api/v2/leads/submit", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", ///curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); CURLOPT_POSTFIELDS => $fields, CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "authorization: Bearer ".$apikey, ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { //= echo $response; } // print_r( $response); if(!empty($response)){ echo "Done"; } exit; } public function review_advisr_member_review() { ?> "https://advisr.com.au/api/v2/brokerages", // CURLOPT_URL => "https://advisr.advisrdev.com.au/api/v2/brokerages", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer ".$apikey, ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { $response; } $array_result = json_decode($response, true); $array_result = $array_result['data']; $reivew=$array_result['reviews']; $reivew_slug=$array_result['profile_url']; $reivew_name=$array_result['name']; $html = ''; $html.='
'; $html.='
'; $html.='
'; foreach($reivew as $reviews_data) { $rating=$reviews_data['rating']; $html.='
'; $html.=''; $html.=''; $html.='
'; } $html.='
'; $html.='
'; $html.='
'; return $html; } public function advisr_toolbox_review_shortcodes() { $plugin_public = new Advisr_Toolbox_Public( $this->get_plugin_name(), $this->get_version() ); //add_shortcode( 'advisr-reviews', array('review_advisr_member_review')); add_shortcode( 'advisr-reviews', array($plugin_public, 'review_advisr_member_review' )); if ( version_compare($GLOBALS['wp_version'], '5.0-beta', '>') ) { // WP > 5 beta add_filter( 'use_block_editor_for_post_type', '__return_false', 100 ); } else { // WP < 5 beta add_filter( 'gutenberg_can_edit_post_type', '__return_false' ); } } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 1.0.0 * @return string The name of the plugin. */ public function get_plugin_name() { return $this->plugin_name; } /** * Retrieve the version number of the plugin. * * @since 1.0.0 * @return string The version number of the plugin. */ public function get_version() { return $this->version; } }