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 // REMOVED - 2.1.3 // ******** $test = $wpdb->get_col("Show columns from $table_name like 'test'"); if(!empty($test)){ $wpdb->query("ALTER TABLE $table_name DROP test"); } //Add column for repeater template alias $alias = $wpdb->get_col("Show columns from $table_name like 'alias'"); if(empty($alias)){ $wpdb->query("ALTER TABLE $table_name ADD alias TEXT NOT NULL"); } // 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 ); $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 Admin CSS wp_enqueue_style( 'admin-css', ALM_ADMIN_URL. 'css/admin.css'); wp_enqueue_style( 'core-css', ALM_URL. '/core/css/ajax-load-more.css'); wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'); //Load CodeMirror Syntax Highlighting if on Repater Template page $screen = get_current_screen(); if ( in_array( $screen->id, array( 'ajax-load-more_page_ajax-load-more-repeaters') ) ){ //CodeMirror CSS wp_enqueue_style( 'codemirror-css', ALM_ADMIN_URL. 'codemirror/lib/codemirror.css' ); //CodeMirror JS wp_enqueue_script( 'codemirror', ALM_ADMIN_URL. 'codemirror/lib/codemirror.js'); wp_enqueue_script( 'codemirror-matchbrackets', ALM_ADMIN_URL. 'codemirror/addon/edit/matchbrackets.js' ); wp_enqueue_script( 'codemirror-htmlmixed', ALM_ADMIN_URL. 'codemirror/mode/htmlmixed/htmlmixed.js' ); wp_enqueue_script( 'codemirror-xml', ALM_ADMIN_URL. 'codemirror/mode/xml/xml.js' ); wp_enqueue_script( 'codemirror-javascript', ALM_ADMIN_URL. 'codemirror/mode/javascript/javascript.js' ); wp_enqueue_script( 'codemirror-mode-css', ALM_ADMIN_URL. 'codemirror/mode/css/css.js' ); wp_enqueue_script( 'codemirror-clike', ALM_ADMIN_URL. 'codemirror/mode/clike/clike.js' ); wp_enqueue_script( 'codemirror-php', ALM_ADMIN_URL. 'codemirror/mode/php/php.js' ); } //Load JS wp_enqueue_script( 'select2', ALM_ADMIN_URL. 'js/libs/select2.min.js', array( 'jquery' )); wp_enqueue_script( 'shortcode-builder', ALM_ADMIN_URL. 'shortcode-builder/js/shortcode-builder.js', array( 'jquery' )); } /* * alm_settings_page * Settings page * * @since 2.0.0 */ function alm_settings_page(){ ?>

     
    '; // include( ALM_PATH . 'admin/includes/cta/extend.php'); // echo '
    '; } // Custom Repeaters v2 - /cta/extend.php if (!has_action('alm_get_unlimited_repeaters')) { if (!has_action('alm_get_custom_repeaters')) { // If Custom Repeaters v1 is NOT installed echo '
    '; include( ALM_PATH . 'admin/includes/cta/extend.php'); echo '
    '; } } ?>

    WordPress loop.

    ', ALM_NAME); ?>

    the_title() and the_permalink() are required.

    ', ALM_NAME); ?>

    • e.g. <li> </li> or <div> </div>', ALM_NAME); ?>
    '. __('Error Opening File', ALM_NAME) .''; $o_error .= ''. $f .''; $o_error .= __('Please check your file path and ensure your server is configured to allow Ajax Load More to read and write files within the /ajax-load-more/ plugin directory', ALM_NAME); $w_error = ''. __('Error Saving File', ALM_NAME) .''; $w_error .= ''. $f .''; $w_error .= __('Please check your file path and ensure your server is configured to allow Ajax Load More to read and write files within the /ajax-load-more/ plugin directory', ALM_NAME); // Open file $o = fopen($f, 'w+') or die($o_error); // Save/Write the file $w = fwrite($o, $c) or die($w_error); // $r = fread($o, 100000); //Read it fclose($o); //now close it //Save to database global $wpdb; $table_name = $wpdb->prefix . "alm"; if($t === 'default') { $data_update = array('repeaterDefault' => "$c", 'pluginVersion' => ALM_VERSION); $data_where = array('name' => "default"); } elseif($t === 'unlimited'){ // Unlimited Repeaters $table_name = $wpdb->prefix . "alm_unlimited"; $data_update = array('repeaterDefault' => "$c", 'alias' => "$a", 'pluginVersion' => ALM_UNLIMITED_VERSION); $data_where = array('name' => $n); } else{ // Custom Repeaters $data_update = array('repeaterDefault' => "$c", 'alias' => "$a", 'pluginVersion' => ALM_REPEATER_VERSION); $data_where = array('name' => $n); } $wpdb->update($table_name , $data_update, $data_where); //Our results if($w){ echo 'Template Saved Successfully'; } else { echo ''. __('Error Writing File', ALM_NAME) .'
    Something went wrong and the data could not be saved.'; } die(); } /* * alm_shortcode_builder_page * Shortcode Builder * * @since 2.0.0 */ function alm_shortcode_builder_page(){ ?>

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


    You can generate shortcodes while editing pages!

    Click the Ajax Load More icon in the content editor toolbar and the shortcode builder will open in an overlay window.', 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(){ ?>

    GitHub repository. ', ALM_NAME); ?>

    repeater templates as you need them with absolutely zero restrictions. The Custom Repeater add-on allows you to create unique layouts for different content types throughout your theme.

    ', ALM_NAME); ?>
    Installed '; }else{ echo ' Purchase & Install'; } ?>

    All add-ons are installed as stand alone plugins and will receive plugin update notifications.', ALM_NAME); ?>

    ' . __('Customize your version of Ajax Load More by updating the fields below.

    All changes will be applied globally throughout 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_NAME).'

    '; ?> '; } /* * alm_class_callback * Add classes to the Ajax Load More wrapper * * @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"'; $selected6 = ''; if($color == 'white') $selected5 = 'selected="selected"'; $html = '
    '; $html .= ''; $html .= '
    '.__('Preview', ALM_NAME) .'
    '; echo $html; ?>