'' ), $atts ); if($_GET["action"]=="result") { include "a2g_tm_result.php"; } else { if(!empty($a['cat'])) { $sql_query = "SELECT * FROM ".$wpdb->prefix."a2g_tm_kategorie WHERE FIND_IN_SET(`catID`, '".$a['cat']."') ORDER BY catSort"; $a2g_tm_built_return .= "
"; } return $a2g_tm_built_return; } //----------------------------------------------------- // do = add a option if is not exist to safe simple css code. best solution ;-P //----------------------------------------------------- if (FALSE === get_option('a2g_tm_output_css') && FALSE === update_option('a2g_tm_output_css',FALSE)) { add_option('a2g_tm_output_css','.a2g-out-html { border:1px solid #000; } .a2g-out-body { background-color:black; color:white; }'); } //----------------------------------------------------- // do = add submenu to wordpress backend //----------------------------------------------------- function a2g_tm_options_submenu() { add_submenu_page( 'options-general.php', 'Text Modules', 'Text Modules', 'administrator', 'a2g_tm_settings', 'a2g_tm_settings_page' ); } //----------------------------------------------------- // do = function for the register_activation_hook // = create database tables //----------------------------------------------------- function a2g_tm_activate() { global $wpdb; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $charset = $wpdb->get_charset_collate(); $charset_collate = $wpdb->get_charset_collate(); // check if tables allready exist $a2g_tm_check_exist_kategorie_table_while_install_update = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."a2g_tm_kategorie"); $a2g_tm_check_exist_texte_table_while_install_update = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."a2g_tm_text"); // when not, create a $sql part 1 if(! $a2g_tm_check_exist_kategorie_table_while_install_update ) { $sql_kategorie = "CREATE TABLE ".$wpdb->prefix."a2g_tm_kategorie ( `catID` INT(11) NOT NULL AUTO_INCREMENT, `catName` VARCHAR(255) NOT NULL, `catDesc` TEXT NOT NULL , `catSort` TEXT NOT NULL , PRIMARY KEY (`catID`) ) $charset_collate; "; } // when not, create a $sql part 2 if(! $a2g_tm_check_exist_texte_table_while_install_update ) { $sql_text = "CREATE TABLE ".$wpdb->prefix."a2g_tm_text ( `textID` INT(11) NOT NULL AUTO_INCREMENT , `catID` INT(11) NOT NULL , `text_ueberschrift` TEXT NOT NULL , `text` TEXT NOT NULL , PRIMARY KEY (`textID`) ) $charset_collate;"; } // check if $sql_text is set -> true = create if(isset($sql_text)) { dbDelta( $sql_kategorie.$sql_text ); } } //----------------------------------------------------- // do = include the require setting file //----------------------------------------------------- function a2g_tm_settings_page() { require "settings_page.php"; } //----------------------------------------------------- // do = load individual CSS File //----------------------------------------------------- function a2g_tm_css() { wp_enqueue_style( 'ada2go-text-modules', plugin_dir_url( __FILE__ ) . 'ada2go-text-modules.css' ); } //----------------------------------------------------- // do = add actions, shortcode, other //----------------------------------------------------- add_shortcode( 'a2gtm', 'a2g_tm' ); add_action( 'wp_enqueue_scripts', 'a2g_tm_css' ); add_action( 'admin_enqueue_scripts', 'a2g_tm_css'); add_action("admin_menu", "a2g_tm_options_submenu"); register_activation_hook( __FILE__, 'a2g_tm_activate' ); //====================================================================== //====================================================================== // // FOLLOWING ARE FUNCTIONS TO GET DATA BY ID OR DATA GENERALLY // //====================================================================== //====================================================================== //----------------------------------------------------- // return = get the number of safed categorys in database // why = using for while counting in settings_page.php //----------------------------------------------------- function a2g_tm_get_highest_cat_sort() { global $wpdb; $a2g_tm_get_highest_cat = $wpdb->get_var("SELECT MAX(catSort) FROM " . $wpdb->prefix . "a2g_tm_kategorie"); return $a2g_tm_get_highest_cat; } //----------------------------------------------------- // att = $a2g_tm_cat is the given category id // return = get the number of safed categorys in database // why = using for while counting in settings_page.php //----------------------------------------------------- function a2g_tm_get_catsort_by_catid( $a2g_tm_cat ) { global $wpdb; $a2g_the_cat = $wpdb->get_var("SELECT catSort FROM " . $wpdb->prefix . "a2g_tm_kategorie WHERE catID = $a2g_tm_cat"); return $a2g_the_cat; } //----------------------------------------------------- // att = $a2g_tm_cat is the given category id // return = select the description of a category id // why = using for output in table and textarea in settings_page.php //----------------------------------------------------- function a2g_tm_edit_cat_by_catid( $a2g_tm_cat ) { global $wpdb; $a2g_the_cat = $wpdb->get_var("SELECT catDesc FROM " . $wpdb->prefix . "a2g_tm_kategorie WHERE catID = $a2g_tm_cat"); return html_entity_decode( $a2g_the_cat ); } //----------------------------------------------------- // att = $a2g_tm_text is the given text id // return = select the text of a text id // why = using for output in table and textarea in settings_page.php //----------------------------------------------------- function a2g_tm_get_text_by_textid( $a2g_tm_text ) { global $wpdb; $a2g_the_text = $wpdb->get_var("SELECT text FROM " . $wpdb->prefix . "a2g_tm_text WHERE textID = $a2g_tm_text"); return html_entity_decode( $a2g_the_text ); } //----------------------------------------------------- // att = $a2g_tm_cat is the given category id // return = select the category name of a category id // why = using for output in table, ids and textarea in settings_page.php //----------------------------------------------------- function a2g_tm_get_cat_by_catid( $a2g_tm_cat ) { global $wpdb; $a2g_the_cat = $wpdb->get_var("SELECT catName FROM " . $wpdb->prefix . "a2g_tm_kategorie WHERE catID = $a2g_tm_cat"); return html_entity_decode( $a2g_the_cat ); } //====================================================================== //====================================================================== // // FOLLOWING ARE FUNCTIONS TO CREATE '; } return $a2g_tm_return_option_sort; } //----------------------------------------------------- // return = generate the html table list for showing categorys //----------------------------------------------------- function a2g_tm_while_categorys() { global $wpdb; $a2g_tm_get_categorys = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."a2g_tm_kategorie ORDER BY catSort"); foreach ( $a2g_tm_get_categorys as $a2g_tm_get_category ) { $a2g_built_category_table .= '