prefix . "alm"; // ********************************************** // If table exists // ********************************************** if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) { // Updated 2.0.5 // Check column 'name' exists in $wpdb - this is an upgrade checker. $row = $wpdb->get_col("Show columns from $table_name like 'name'"); if(empty($row)){ $wpdb->query("ALTER TABLE $table_name ADD name TEXT NOT NULL"); $wpdb->update($table_name , array('name' => 'default'), array('id' => 1)); } // ******** // @TO-DO - Upgrade test, will remove in future versions // ******** $test = $wpdb->get_col("Show columns from $table_name like 'test'"); if(empty($test)){ $wpdb->query("ALTER TABLE $table_name ADD test TEXT NOT NULL"); $wpdb->update($table_name , array('test' => 'test value'), array('id' => 1)); } // Compare versions of repeaters, if template versions do not match, update the repeater with value from DB $version = $wpdb->get_var("SELECT pluginVersion FROM $table_name WHERE name = 'default'"); if($version != ALM_VERSION){ // First, make sure versions do not match. //Write to repeater file $data = $wpdb->get_var("SELECT repeaterDefault FROM $table_name WHERE name = 'default'"); $f = ALM_PATH. 'core/repeater/default.php'; // File $o = fopen($f, 'w+'); //Open file $w = fwrite($o, $data); //Save the file $r = fread($o, 100000); //Read it fclose($o); //now close it } } // ********************************************** // If table DOES NOT exist, create it. // ********************************************** if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $createRepeater = '
  • '; $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, name text NOT NULL, repeaterDefault longtext NOT NULL, pluginVersion text NOT NULL, UNIQUE KEY id (id) );"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); //Insert default data in newly created table $wpdb->insert($table_name , array('name' => 'default', 'repeaterDefault' => $createRepeater, 'pluginVersion' => ALM_VERSION)); } } /** * alm_admin_menu * Create Admin Menu * * @since 2.0.0 */ add_action( 'admin_menu', 'alm_admin_menu' ); function alm_admin_menu() { $icon = 'dashicons-plus-alt'; $icon = ALM_ADMIN_URL . "/img/alm-logo-16x16.png"; $alm_page = add_menu_page( 'Ajax Load More', 'Ajax Load More', 'edit_theme_options', 'ajax-load-more', 'alm_settings_page', $icon, 81 ); $alm_settings_page = add_submenu_page( 'ajax-load-more', 'Settings', 'Settings', 'edit_theme_options', 'ajax-load-more', 'alm_settings_page'); $alm_template_page = add_submenu_page( 'ajax-load-more', 'Repeater Templates', 'Repeater Templates', 'edit_theme_options', 'ajax-load-more-repeaters', 'alm_repeater_page'); $alm_shortcode_page = add_submenu_page( 'ajax-load-more', 'Shortcode Builder', 'Shortcode Builder', 'edit_theme_options', 'ajax-load-more-shortcode-builder', 'alm_shortcode_builder_page'); $alm_examples_page = add_submenu_page( 'ajax-load-more', 'Examples', 'Examples', 'edit_theme_options', 'ajax-load-more-examples', 'alm_example_page'); $alm_addons_page = add_submenu_page( 'ajax-load-more', 'Add-ons', 'Add-ons', 'edit_theme_options', 'ajax-load-more-add-ons', 'alm_add_ons_page'); //Add our admin scripts add_action( 'load-' . $alm_settings_page, 'alm_load_admin_js' ); add_action( 'load-' . $alm_template_page, 'alm_load_admin_js' ); add_action( 'load-' . $alm_shortcode_page, 'alm_load_admin_js' ); add_action( 'load-' . $alm_examples_page, 'alm_load_admin_js' ); add_action( 'load-' . $alm_addons_page, 'alm_load_admin_js' ); } /** * alm_load_admin_js * Load Admin JS * * @since 2.0.15 */ function alm_load_admin_js(){ add_action( 'admin_enqueue_scripts', 'alm_enqueue_admin_scripts' ); } /** * alm_enqueue_admin_scripts * Enqueue Admin JS * * @since 2.0.15 */ function alm_enqueue_admin_scripts(){ //Load CSS wp_enqueue_style( 'admin-css', ALM_ADMIN_URL. 'css/admin.css'); wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css'); //Load JS wp_enqueue_script( 'select2', ALM_ADMIN_URL. 'js/libs/select2.min.js', array( 'jquery' )); wp_enqueue_script( 'shortcode-builder', ALM_ADMIN_URL. 'js/shortcode-builder.js', array( 'jquery' )); } /* * alm_settings_page * Settings page * * @since 2.0.0 */ function alm_settings_page(){ ?>

    A simple solution for lazy loading WordPress posts and pages

     
    '; include( ALM_PATH. 'admin/includes/cta/extend.php'); echo '
    '; } ?>
    prefix . "alm"; if($n === 'default'){ $data_update = array('repeaterDefault' => "$c", 'pluginVersion' => ALM_VERSION); $data_where = array('name' => "default"); }else{ $data_update = array('repeaterDefault' => "$c", 'pluginVersion' => ALM_REPEATER_VERSION); $data_where = array('name' => $n); } $wpdb->update($table_name , $data_update, $data_where); //Our results if($w){ echo 'File saved'; } else { echo 'Error saving file'; } } /* * alm_shortcode_builder_page * Shortcode Builder * * @since 2.0.0 */ function alm_shortcode_builder_page(){ ?>

    shortcode by adjusting the values below', ALM_NAME); ?>

    'name', 'order' => 'ASC', 'hide_empty' => false ); $terms = get_terms($taxonomy, $tax_args); $returnVal = ''; if ( !empty( $terms ) && !is_wp_error( $terms ) ){ $returnVal .= ''; echo $returnVal; die(); }else{ echo "

    No terms exist within this taxonomy

    "; die(); } } /* * alm_example_page * Examples Page * * @since 2.0.0 */ function alm_example_page(){ ?>

    five additional repeaters and allow you to select unique repeaters for different content types throughout your theme.

    It\'s easy, seriously! Simply build each repeater just the way you want them, then select a template from the list of available templates while building your shortcode.

    Read/Write Access is required!

    ', ALM_NAME); ?>
    Installed '; }else{ echo ' Purchase & Install'; } ?>
    ' . __('Customize your version of Ajax Load More by updating the fields below.

    All changes will be applied globally accross your theme.', ALM_NAME) . '

    '; } /* * alm_sanitize_settings * Sanitize our form fields * * @since 2.0.0 */ function alm_sanitize_settings( $input ) { return $input; } /* * alm_disable_css_callback * Diabale Ajax Load More CSS. * * @since 2.0.0 */ function alm_disable_css_callback(){ $options = get_option( 'alm_settings' ); if(!isset($options['_alm_disable_css'])) $options['_alm_disable_css'] = '0'; echo ' '; echo '

     View Ajax Load More CSS

    '; } /* * alm_html5_callback * Enable HTML5 elements within AjaxLoadMore. * * @since 2.0.0 */ function alm_html5_callback(){ $options = get_option( 'alm_settings' ); if(!isset($options['_alm_html5'])) $options['_alm_html5'] = '1'; echo ' '; } /* * alm_class_callback * Enable HTML5 elements within AjaxLoadMore. * * @since 2.0.0 */ function alm_class_callback(){ $options = get_option( 'alm_settings' ); echo '
    '; } /* * alm_container_type_callback * The type of container ul or div * * @since 2.0.0 */ function alm_container_type_callback() { $options = get_option( 'alm_settings' ); if(!isset($options['_alm_container_type'])) $options['_alm_container_type'] = '1'; $html = ''; $html .= '
    '; $html .= ''; $html .= ''; echo $html; } /* * alm_btn_color_callback * Get button color * * @since 2.0.0 */ function alm_btn_color_callback() { $options = get_option( 'alm_settings' ); $color = $options['_alm_btn_color']; if(!isset($color)) $options['_alm_btn_color'] = '0'; $selected0 = ''; if($color == 'default') $selected0 = 'selected="selected"'; $selected1 = ''; if($color == 'blue') $selected1 = 'selected="selected"'; $selected2 = ''; if($color == 'green') $selected2 = 'selected="selected"'; $selected3 = ''; if($color == 'red') $selected3 = 'selected="selected"'; $selected4 = ''; if($color == 'purple') $selected4 = 'selected="selected"'; $selected5 = ''; if($color == 'grey') $selected5 = 'selected="selected"'; $html = ''; echo $html; }