Built the Shortcode for the Frontend
*/
function a2g_tm( $atts ) {
global $wpdb;
if($_GET["action"]=="result") { include "a2g_tm_result.php"; } else {
$a2g_tm_built_return .= "
";
}
return $a2g_tm_built_return;
}
add_shortcode( 'a2gtm', 'a2g_tm' );
/**
* Add the Submenu to Settings
*/
function a2g_tm_options_submenu() {
add_submenu_page(
'options-general.php',
'Text Modules',
'Text Modules',
'administrator',
'a2g_tm_settings',
'a2g_tm_settings_page' );
}
/**
* Require settings_page.php
*/
function a2g_tm_settings_page() {
require "settings_page.php";
}
/**
* LOAD individual CSS File
*/
function a2g_tm_css() {
wp_enqueue_style( 'ada2go-text-modules', plugin_dir_url( __FILE__ ) . 'ada2go-text-modules.css' );
}
add_action( 'wp_enqueue_scripts', 'a2g_tm_css' );
add_action( 'admin_enqueue_scripts', 'a2g_tm_css');
/**
* ADD submenu to Settings
*/
add_action("admin_menu", "a2g_tm_options_submenu");
/**
* ACTIVATION
* Create Database Table
*/
function a2g_tm_activate() {
global $wpdb;
$charset = $wpdb->get_charset_collate();
$charset_collate = $wpdb->get_charset_collate();
/**
* SET sql String
*/
$sql = "CREATE TABLE ".$wpdb->prefix."a2g_tm_kategorie (
`catID` INT(11) NOT NULL AUTO_INCREMENT,
`catName` VARCHAR(255) NOT NULL,
`catDesc` TEXT NOT NULL ,
PRIMARY KEY (`catID`)
) $charset_collate;
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;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
}
// hook on activation
register_activation_hook( __FILE__, 'a2g_tm_activate' );
/**
* Function: a2g_tm_while_categorys
* => Output the Categorys in Table
*/
function a2g_tm_while_categorys() {
global $wpdb;
$a2g_tm_get_categorys = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."a2g_tm_kategorie");
foreach ( $a2g_tm_get_categorys as $a2g_tm_get_category ) {
$a2g_built_category_table .= '
| ' . $a2g_tm_get_category->catID . ' |
' . $a2g_tm_get_category->catName . '
' . __(
'löschen', 'ada2go-text-modules' ) . ' | '. __(
'bearbeiten', 'ada2go-text-modules' ) .' |
' . $a2g_tm_get_category->catDesc . ' |
';
}
return $a2g_built_category_table;
}
/**
* Function: a2g_tm_while_textes
* => Output the Text in Table
*/
function a2g_tm_while_textes() {
global $wpdb;
$a2g_tm_get_textes = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "a2g_tm_text");
foreach ( $a2g_tm_get_textes as $a2g_tm_get_text ) {
$a2g_built_text_table .= '
| ' . $a2g_tm_get_text->textID . ' |
' . $a2g_tm_get_text->text . '
'.__(
'löschen', 'ada2go-text-modules' ).' | '. __(
'bearbeiten', 'ada2go-text-modules' ) . ' |
' . $a2g_tm_get_text->catID . ' |
';
}
return $a2g_built_text_table;
}
/**
* Function: a2g_tm_while_safed_textes
* => Output the Text in Table
*/
function a2g_tm_while_safed_textes() {
global $wpdb;
$directory = ABSPATH . 'wp-content/plugins/ada2go-text-modules/reslut-safes/';
$files = glob($directory . '*.{html}', GLOB_BRACE);
foreach($files as $file)
{
$path = parse_url($file, PHP_URL_PATH);
$path = basename($path);
echo "Pfad: ".$file." Datei öffnen | Datei löschen" . " |
";
}
return;
}
/**
* Function: a2g_tm_get_text_by_textid
* => Return the text by given ID
*/
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 $a2g_the_text;
}
/**
* Function: a2g_tm_get_cat_by_catid
* => Return the category Name by given ID
*/
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 $a2g_the_cat;
}
/**
* Function: a2g_tm_edit_text_by_textid
* => Return the text of a textID given
*/
function a2g_tm_edit_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 $a2g_the_text;
}
/**
* Function: a2g_tm_edit_cat_by_catid
* => Return the describtion of a categoryID given
*/
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 $a2g_the_cat;
}