Skip to content

Commit

Permalink
Bug Fixes and new features
Browse files Browse the repository at this point in the history
  • Loading branch information
MB-Jan committed Feb 7, 2022
1 parent 13e4793 commit a90b897
Show file tree
Hide file tree
Showing 29 changed files with 1,338 additions and 143 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# iko.travel WordPress plugin documentation #
# iko.travel Affiliate WordPress plugin documentation #

### Project information ###

Expand Down
42 changes: 42 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
=== iko.travel Affiliate ===
Contributors: MB-Jan
Tags: travel, iko, booking
Requires at least: 4.7
Tested up to: 5.7.2
Stable tag: 4.3
Requires PHP: 7.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Integrates WordPress with your iko.travel seller account. Learn more at [https://sell.iko.travel](https://sell.iko.travel "Your favorite travel inventory software").

== Description ==

Once you've created an account with iko.travel, you can install this WordPress plugin on your site. Once installed, the plugin will ask you for your clientId and secretKey to connect with your account on iko.travel.

Once you've entered your credentials, you can go to your Gutenberg editor and start embedding our web components into your site.

Available components:

* [ikolookup]: Works with ranked content grid. Type in a place you want to visit and have inventory displayed.
* [ikosearch]: Simple button to open up itinerary form.
* [ikoaccount]Account: Button to let you authenticate. Once authenticated, it turns into a dropdown with account options.
* [ikoitinerary]Itinerary: Same as search button, only it contains itinerary information as button text.
* [ikocontent]: Lets you embed the inventory you've selected on iko.travel directly into a page or post.

== Options ==
There are multiple ways to use our components:

1. By selecting our custom Gutenberg, Elementor, WPBakery or Avada blocks directly in the editor
2. Using the shortcode that accompanies each web component

== Support ==

* Support: bjorn@iko.travel

[https://sell.iko.travel](https://sell.iko.travel "Your favorite travel inventory software")

== Changelog ==

= 1.0.19 =
* Initial Launch
62 changes: 49 additions & 13 deletions ikoTravel.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,67 @@
<?php
/**
* Plugin Name: iko.travel
* Plugin URI: https://iko.travel/
* Description: This plugin integrates your iko.travel account with WordPress. It integrates with Gutenberg and as shortcodes.
* Version: 1.0.16
* Plugin Name: iko.travel Affiliate
* Description: This plugin integrates your iko.travel affiliate account with WordPress. It integrates with Gutenberg, Elementor, Avada, WPBakery and as shortcodes.
* Version: 1.0.25
* Author: iko.travel
* Author URI: https://iko.travel/
* License: GPL-3.0
* License URI: https://oss.ninja/gpl-3.0?organization=Useful%20Team&project=jwt-auth
* Text Domain: iko-travel
*
* the iko.travel Affiliate WordPress plugin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
* iko.travel Affiliate WordPress plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with iko.travel Affiliate WordPress plugin. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
*/
if ( ! defined( 'ABSPATH' ) ) exit;

class ikoTravel {
function __construct() {
$this->version = '1.0.16';
$this->version = '1.0.4';
$this->namespace = 'iko-travel';
$this->section = 'ikoTravel'; // Customizer Section Name
$this->clientIdKey = 'ikoTravelClientId';
$this->clientSecretKey = 'ikoTravelSecret';
$this->environment = 'ikoEnvironment';
$this->environmentVal = get_option($this->environment, false);
$this->pluginURL = trailingslashit( plugin_dir_url( __FILE__ ) );
$this->settingsURL = admin_url( '/customize.php?autofocus[section]='.$this->section);
add_action( 'customize_register', array( $this,'addSettings' ) ); // adding plugin settings to WP Customizer
add_action('admin_notices', array( $this,'adminNotice' ) ); // adding admin notice if client id has not been entered
//add_shortcode('ikoTravel', array( $this,'blockHandler' ) ); // Adding Shortcode
add_filter( 'block_categories', array( $this,'gutenbergBlockCategory' ), 10, 2); // Adding custom Gutenberg Block Category
add_filter( 'block_categories_all', array( $this,'gutenbergBlockCategory' ), 10, 2); // Adding custom Gutenberg Block Category
//add_action('init', array( $this,'gutenbergBlockRegistration' ) ); // Adding Gutenberg Block
add_action( 'wp_enqueue_scripts', array($this, 'loadScripts' )); // too resource intensive to search all pages for iko.travel elements. Scripts need to be added all the time.

add_filter( 'clean_url', array($this,'jsHelper'), 11, 1 ); // Helper to add attribute to js tag
add_action( 'admin_enqueue_scripts', array($this,'customizeScripts'));

add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'settingsLink' ));
}

function settingsLink( $links ) {
// Build and escape the URL.
$url = esc_url( add_query_arg(
'page',
'nelio-content-settings',
get_admin_url() . 'admin.php'
) );
// Create the link.
$settings_link = '<a href="'.$this->settingsURL.'" title="'.__('iko.travel settings',$this->namespace).'">' . __( 'Settings',$this->namespace ) . '</a>';
// Adds the link to the end of the array.
array_push(
$links,
$settings_link
);
return $links;
}
function customizeScripts() {
if (!isset($_GET['ikoadmin']) && !isset($_GET['ikoAdmin'])) {
Expand Down Expand Up @@ -69,7 +99,7 @@ function adminNotice() {
__('Congratulations', $this->namespace).
'</b> '.
__('on installing the official iko.travel WordPress plugin.',$this->namespace).
' <a href="'.admin_url( '/customize.php?autofocus[section]='.$this->section ).'" title="'.__('iko.travel settings',$this->namespace).'">'.
' <a href="'.$this->settingsURL.'" title="'.__('iko.travel settings',$this->namespace).'">'.
__('Click here',$this->namespace).
'</a> '.
__('to add your iko.travel Client-ID and your Client-Secret',$this->namespace).
Expand All @@ -91,10 +121,16 @@ function adminNotice() {
}
}
}

function addSettings( $wp_customize ) {
$shortcodes = array();
$shortcodes = apply_filters( 'ikoShortcodes', $shortcodes);
$allShortcodes = apply_filters( 'ikoShortcodes', $shortcodes);
if (!empty($allShortcodes)) {
foreach ($allShortcodes as $key => $shortcodeData) {
if (!empty($shortcodeData['code'])) {
$shortcodes[] = '['.$shortcodeData['code'].']';
}
}
}
$wp_customize->add_section( $this->section, array(
'title' => __( 'iko.travel Settings', $this->namespace ),
'priority' => 30,
Expand Down Expand Up @@ -164,9 +200,9 @@ static function environmentURL($target, $environment) {
'production' => 'https://elements.iko.travel'
);
$jsonEnvironments = array(
'staging' => 'https://staging.0101.network',
'development' => 'https://dev.traveliko.com:8443',
'production' => 'https://0101.network'
'staging' => 'https://staging-api.iko.travel',
'development' => ' https://staging-iam.iko.travel',
'production' => 'https://iam.iko.travel'
);

switch ($target) {
Expand All @@ -192,4 +228,4 @@ static function environmentURL($target, $environment) {

if (!empty(get_option('ikoTravelClientId', false)) && function_exists('curl_version')) {
require_once('includes/elementHandler.php'); // Handles all iko.travel Elements (Only load it if the client id is present)
}
}
7 changes: 6 additions & 1 deletion includes/elementHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function coreComponent() {
$html = '';
$clientId = get_option($this->clientIdKey, false);

$html .= '<iko-app-loader config=\'{"client-id":"'.$clientId.'"}\'></iko-app-loader>';
$html .= '<iko-app-loader config=\'{"clientId":"'.$clientId.'"}\'></iko-app-loader>';

echo $html;
$GLOBALS['ikoTravelLoaderAlreadyEnqueued'] = true;
Expand All @@ -35,6 +35,11 @@ function coreComponent() {

require_once('elements/ikolookup.php'); // Lookup element
require_once('elements/ikoitinerary.php'); // Itinerary button element
require_once('elements/ikoitineraryform.php'); // Itinerary form element
require_once('elements/ikosearch.php'); // Search button element
require_once('elements/ikoaccount.php'); // Account button element
require_once('elements/ikocontent.php'); // Content element

require_once('elements/wpbakery/vcElements.php'); // WPBakery Page Builder
require_once('elements/elementor/elementorWidgets.php'); // Elementor
require_once('elements/avada/fusionElements.php'); // Avada / Fusion Builder
39 changes: 39 additions & 0 deletions includes/elements/avada/fusionElements.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;

class fusionElements extends ikoTravelElements {
function __construct() {
add_action('init', array($this, 'checkIfEnabled'));
}
function checkIfEnabled() {
parent::__construct();
add_action( 'fusion_builder_before_init', array( $this, 'initElements' ));

}
function initElements() {
if (function_exists('fusion_builder_map')) {
$shortcodes = array();
$shortcodes = apply_filters( 'ikoShortcodes', $shortcodes);
foreach ($shortcodes as $key => $shortcodeData) {
$params = $shortcodeData['params'];
if (!empty($params)) {
foreach($params as $paramKey => $param) {
if (!empty($param['type']) && $param['type'] == 'dropdown') {
$params[$paramKey]['type'] = 'select';
}
}
}
fusion_builder_map( array(
"name" => $shortcodeData['name'],
"shortcode" => $shortcodeData['code'],
"class" => "",
"category" => __( "Content", $this->namespace),
"icon" => 'fusion-module-icon fusiona-widget',
"params" => $params
));
}
}
}
}

$vsElements = new vcElements();
1 change: 1 addition & 0 deletions includes/elements/avada/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php // Silence is golden
24 changes: 24 additions & 0 deletions includes/elements/css/_itineraryform.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
body {
.ikoitineraryform {
width: 100%;
text-align: center;
border: none;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
padding: 0;
background-color: #F8F9FA;
padding: 10px 5px;
img {
display: inline;
margin: 0;
width: 14px;
vertical-align: middle;
margin-bottom: 3px;
}
div {
display: inline-block;
margin-left: 8px;
font-size: 0.8em;
}
}
}
23 changes: 23 additions & 0 deletions includes/elements/css/elements.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/elements/css/elements.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions includes/elements/css/elements.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use "search";
@use "account";
@use "itinerary";
@use "itineraryform";
@use "lookup";
@use "content";
22 changes: 22 additions & 0 deletions includes/elements/elementor/elementorControls.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;

class ikoDefault extends \Elementor\Base_Control {
public $namespace;
public function get_type() {
return 'ikoDefault';
}

public function content_template() {
$this->namespace = 'iko-travel';
?>
<div class="elementor-control-field">
<div class="elementor-control-input-wrapper"><b><?= __( "This component does not require any configuration.", $this->namespace ); ?></b></div>
</div>
<div class="elementor-control-field">
<div class="elementor-control-input-wrapper"><?=__( "Simply ensure that you have entered the correct Client-ID and Client-Secret ", $this->namespace ) . ' <a href="'.admin_url( '/customize.php?autofocus[section]=ikoTravel').'" title="'.__('iko.travel settings',$this->namespace).'" target="_blank">'.__('here',$this->namespace).'</a>'; ?> </div>
</div>
<?php
}

}
40 changes: 40 additions & 0 deletions includes/elements/elementor/elementorWidgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;

class elementorWidgets extends ikoTravelElements {
function __construct() {
add_action('init', array($this, 'checkIfEnabled'));

add_action( 'elementor/controls/controls_registered', [ $this, 'register_controls' ] );
}
public function register_controls() {
require_once('elementorControls.php');
$controls_manager = \Elementor\Plugin::$instance->controls_manager;
$controls_manager->register_control( 'ikoDefault', new ikoDefault() );

}
function checkIfEnabled() {
if( defined( 'ELEMENTOR_VERSION' ) ) {
parent::__construct();
add_action( 'elementor/widgets/widgets_registered', function() {


require_once('ikoaccount.php');
require_once('ikoitinerary.php');
require_once('ikolookup.php');
require_once('ikosearch.php');
require_once('ikocontent.php');
require_once('ikoitineraryform.php');
// Let Elementor know about our widget
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new elementorIkoAccount() );
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new elementorIkoitinerary() );
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new elementorIkoLookup() );
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new elementorIkoSearch() );
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new elementorIkoContent() );

});
}
}
}

$elementorWidgets = new elementorWidgets();
Loading

0 comments on commit a90b897

Please sign in to comment.