Skip to content

Commit

Permalink
Merge pull request #26 from AyeCode/master
Browse files Browse the repository at this point in the history
pull
  • Loading branch information
kprajapatii authored Mar 23, 2020
2 parents 2dbe0cc + 94c4266 commit 2143bad
Show file tree
Hide file tree
Showing 14 changed files with 1,855 additions and 472 deletions.
4 changes: 4 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
* File limit not working for custom field field - FIXED
* Add field visibility check for email in ninja form widget - FIXED
* Allow to show field raw value with gd_post_meta - CHANGED
* Elementor dynamic content support - ADDED
* Advanced DB Default option added for when adding new custom field - ADDED
* Changes for scheme Event Status - CHANGED
* Image function can add wrong sizes to image tag - FIXED

= 2.0.0.81 =
* Remove title/meta variables not related to location page - CHANGED
Expand Down
8 changes: 4 additions & 4 deletions geodirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* Plugin Name: GeoDirectory
* Plugin URI: https://wpgeodirectory.com/
* Description: GeoDirectory plugin for WordPress.
* Version: 2.0.0.81
* Version: 2.0.0.82
* Author: AyeCode Ltd
* Author URI: https://wpgeodirectory.com
* Text Domain: geodirectory
* Domain Path: /languages
* Requires at least: 4.5
* Tested up to: 5.3.2
* Tested up to: 5.4
*/


Expand All @@ -35,7 +35,7 @@ final class GeoDirectory {
*
* @var string
*/
public $version = '2.0.0.81';
public $version = '2.0.0.82';

/**
* GeoDirectory instance.
Expand Down Expand Up @@ -221,7 +221,7 @@ private function includes() {
GeoDir_Compatibility::init(); // plugin/theme comaptibility checks

if( defined( 'ELEMENTOR_VERSION' ) ){
new GeoDir_Elementor();
GeoDir_Elementor::init();
}

GeoDir_SEO::init();
Expand Down
19 changes: 12 additions & 7 deletions includes/admin/settings/class-geodir-settings-cpt-cf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ private static function sanatize_custom_field($input){
}
}
$field->default_value = $default_value;
$field->db_default = isset( $input['db_default'] ) ? sanitize_text_field( esc_attr( $input['db_default'] ) ) : '';
$field->placeholder_value = isset( $input['placeholder_value'] ) ? sanitize_text_field( esc_attr( $input['placeholder_value'] ) ) : '';
$field->sort_order = isset( $input['sort_order'] ) ? intval( $input['sort_order'] ) : self::default_sort_order();
$field->is_active = isset( $input['is_active'] ) ? absint( $input['is_active'] ) : 0;
Expand Down Expand Up @@ -1970,9 +1971,9 @@ public static function save_custom_field($field = array()){
// break;
case 'checkbox':
$column_attr .= "( 1 ) NULL ";
// if ((int)$field->default_value === 1) {
// $column_attr .= " DEFAULT '1'";
// }
if (isset($field->db_default) && (int)$field->db_default === 1) {
$column_attr .= " DEFAULT '1'";
}
break;
case 'multiselect':
case 'select':
Expand Down Expand Up @@ -2006,9 +2007,9 @@ public static function save_custom_field($field = array()){
}

$column_attr .= "( $op_size ) NULL ";
// if ($field->default_value != '') {
// $column_attr.= $wpdb->prepare(" DEFAULT %s ",$field->default_value);
// }
if ($field->db_default != '') {
$column_attr.= $wpdb->prepare(" DEFAULT %s ",$field->db_default);
}

// Update the field size to new max
if($exists) {
Expand Down Expand Up @@ -2036,7 +2037,11 @@ public static function save_custom_field($field = array()){
}else{
$column_attr .= "( 254 ) NULL ";
}
//print_r($extra_fields);print_r($field);exit;

if ($field->db_default != '') {
$column_attr.= $wpdb->prepare(" DEFAULT %s ",$field->db_default);
}

break;
case 'int':
case 'INT':
Expand Down
47 changes: 47 additions & 0 deletions includes/admin/views/html-admin-settings-cpt-cf-setting-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,53 @@
<?php
}

// db_default, this only shows on first add
if(isset($field->id) && !is_numeric($field->id)) {
do_action( "geodir_cfa_before_db_default_{$field->field_type}", $cf, $field );

if ( has_filter( "geodir_cfa_db_default_{$field->field_type}" ) ) {

echo apply_filters( "geodir_cfa_db_default_{$field->field_type}", '', $field->id, $cf, $field );

} else {
$value = '';
if ( isset( $field->db_default ) ) {
$value = esc_attr( $field->db_default );
} elseif ( isset( $cf['defaults']['db_default'] ) && $cf['defaults']['db_default'] ) {
$value = $cf['defaults']['db_default'];
}
?>
<p class="gd-advanced-setting" data-setting="db_default">
<label for="db_default" class="dd-setting-name">
<?php
if ( $field->field_type == 'checkbox' ) {
echo geodir_help_tip( __( 'Should the value be set by default in the database?', 'geodirectory' ) );
} else if ( $field->field_type == 'email' ) {
echo geodir_help_tip( __( 'A default database value for the field, usually blank.', 'geodirectory' ) );
} else {
echo geodir_help_tip( __( 'A default database value for the field, usually blank.', 'geodirectory' ) );
}
_e( 'Database Default value', 'geodirectory' ); ?>
<?php if ( $field->field_type == 'checkbox' ) { ?>
<select name="db_default" id="db_default">
<option value=""><?php _e( 'Unchecked', 'geodirectory' ); ?></option>
<option
value="1" <?php selected( true, (int) $value === 1 ); ?>><?php _e( 'Checked', 'geodirectory' ); ?></option>
</select>
<?php } else if ( $field->field_type == 'email' ) { ?>
<input type="email" name="db_default"
placeholder="<?php _e( '[email protected]', 'geodirectory' ); ?>"
id="db_default" value="<?php echo esc_attr( $value ); ?>"/><br/>
<?php } else { ?>
<input type="text" name="db_default" id="db_default"
value="<?php echo esc_attr( $value ); ?>"/><br/>
<?php } ?>
</label>
</p>
<?php
}
}

// placeholder_value
do_action( "geodir_cfa_before_placeholder_value_{$field->field_type}", $cf, $field);

Expand Down
6 changes: 3 additions & 3 deletions includes/class-geodir-autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public function autoload( $class ) {
$file = $this->get_file_name_from_class( $class );
$path = '';

if ( strpos( $class, 'geodir_shortcode_' ) === 0 ) {
$path = $this->include_path . 'shortcodes/';
} elseif ( strpos( $class, 'geodir_admin' ) === 0 ) {
if ( strpos( $class, 'geodir_admin' ) === 0 ) {
$path = $this->include_path . 'admin/';
}elseif ( strpos( $class, 'geodir_widget' ) === 0 ) {
$path = $this->include_path . 'widgets/';
}elseif ( strpos( $class, 'geodir_settings' ) === 0 ) {
$path = $this->include_path . 'admin/settings/';
}elseif ( strpos( $class, 'geodir_elementor' ) === 0 ) {
$path = $this->include_path . 'elementor/';
}

if ( empty( $path ) || ! $this->load_file( $path . $file ) ) {
Expand Down
Loading

0 comments on commit 2143bad

Please sign in to comment.