Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Walker committed Jan 22, 2019
0 parents commit 5451675
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 InCuca Tecnologia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ic-enfold-search
Enfold search plugin
48 changes: 48 additions & 0 deletions css/ic-enfold-search.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.ic-enfold-search {
position: relative;
max-width: 540px;
margin-left: auto;
margin-right: auto;
}
.ic-enfold-search .widget_search {
position: absolute;
right: 0;
bottom: 0;
left: 0;
z-index: 100;
}

#top .ic-enfold-search #searchform > div.ajax_search_response {
position: absolute;
padding-top: 10px;
width: 100%;
background-color: #3e3e3e;
box-shadow: 1px 1px 10px 0px black;
}

#top #header_main > .container {
height: auto !important;
line-height: 1 !important;
}

.logo a {
height: 90px;
}

@media only screen and (max-width: 989px) and (max-width: 767px) {
.ic-enfold-search {
padding-top: 0 !important;
height: auto !important;
}

.ic-enfold-search .widget_search {
position: static;
}
}

@media only screen and (max-width: 989px) and (min-width: 768px) {
.responsive.html_mobile_menu_tablet #top #wrap_all .av-logo-container {
height: auto !important;
line-height: 1 !important;
}
}
76 changes: 76 additions & 0 deletions ic-enfold-search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Plugin Name: Enfold Search
* Plugin URI: https://incuca.net
* Description: Enfold Search Plugin
* Author: INCUCA
* Author URI: https://incuca.net
* Text Domain: ic-enfold-search
* Version: 0.1.0
*
* @package Ic_Enfold
*/

function recursive_array_search($needle,$haystack) {
foreach($haystack as $key=>$value) {
$current_key=$key;
if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value) !== false)) {
return $current_key;
}
}
return false;
}

function isEnabled($post) {
$enabled = get_post_meta( $post->ID, '_ic_enfold_search', true );
return $enabled !== 'no';
}

function ic_enfold_search_builder_elements($elements) {
$posttype = avia_backend_get_post_type();
if ($posttype !== 'page') return $elements;
$titleElementIndex = recursive_array_search('header_title_bar', $elements);
$element = array(
"slug" => "layout",
"name" => __("Enfold Search Settings",'ic_enfold_search'),
"desc" => __("Display the Search Field below menu?",'ic_enfold_search'),
"id" => "_ic_enfold_search",
"type" => "select",
"std" => "no",
"class" => "avia-style",
"subtype" => array(
__("No",'ic_enfold_search') => 'no',
__('Yes','ic_enfold_search') =>'yes',
),

);
array_splice($elements, $titleElementIndex, 0, array($element));
return $elements;
}
add_filter('avf_builder_elements', 'ic_enfold_search_builder_elements');

function ic_enfold_search_after_main_menu() {
global $post;
if (isEnabled($post)) {
$settings = avia_header_setting();
$style = "";
if($settings['header_size'] == "custom") {
$size = $settings['header_custom_size'];
$style = ' style="padding-top: ' . $size . 'px; height: ' . intval($size) * 2 . 'px;"';
}

echo '<div class="ic-enfold-search"' . $style .'>';
the_widget('WP_Widget_Search');
echo '</div>';
}
}
add_action('ava_after_main_menu', 'ic_enfold_search_after_main_menu');

function ic_enfold_search_scripts() {
global $post;
if (isEnabled($post)) {
$plugin_dir = plugin_dir_url(__FILE__);
wp_enqueue_style( 'ic-enfold-search' , $plugin_dir.'css/ic-enfold-search.css' , array(), false );
}
}
add_action('wp_enqueue_scripts', 'ic_enfold_search_scripts');
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

<?php
// Silence is golden.

0 comments on commit 5451675

Please sign in to comment.