Modulentwicklung

 

Gliederung

  • Basics

  • Datenbankanbindungen

  • bestehende Entwicklungen

"einhaken"

filter

action

default hooks

custom hooks

<?php
    add_action(‘custom_hook‘, ‘cool_function‘);
    do_action(‘custom_hook’); 
?>
<?php
    add_action ( 'the_content', 'say_hello');
    function say_hello($post_ID)  {
    	echo 'Hello world.';
    return $post_ID;
    }
?>

Inhalte/Text - hinzufügen/ändern/durchführen

<?php
	/*
		Plugin Name: Kleiner
		Description: schreibt alles klein 
		Version: 1.0
		Author: Cafer Oezer
		Min WP Version: 1.5
		Max WP Version: 2.0.4
	*/
	add_filter('the_content', 'strtolowerContent');

	function strtolowerContent($content) {
		return  strtolower($content);
	}
?>

Funktionen - hinzufügen/ändern/durchführen

<?php
    /*
    Plugin Name: CT-Hello-World
    Description: Hallo-World-Pluging
    Version: 1.0
    Author: cmaran
    */
    	
    add_action ( 'the_content', 'say_hello');
    
    function say_hello($post_ID)  {
    	echo 'Hello world.';
    return $post_ID;
    }
?>

FB-Like plugin

<?php
    /*
    Plugin Name: CT-FB-LIKE
    Description: Facebook Like Button Plugin
    Version: 1.0
    Author: cmaran
    */
    
    add_action ( 'the_content', 'fb_like');
    
    function fb_like($post_ID)  {
?>
<iframe 
    src="http://www.facebook.com/plugins/like.php?href=
        <?php echo urlencode('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); ?>
        &layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80"
        scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
<?php
        return $post_ID;
        }rn $post_ID;
    }
?>

Datenbank schnittstellen

  • MySQL
  • PostgreSQL
  • etc.

mysql

<?php
	/*
		Plugin Name: Show MySQL Tables
		Description: Das Plugin verbindet sich mit der MySQL-Datenbank und gibt uns alle Tabellen aus. 
		Version: 1.0
		Author: Cafer Oezer
		Min WP Version: 1.5
		Max WP Version: 2.0.4
	*/
	
	if(!isset($_SESSION)) {
		session_start();
	}
	
	$server = 'localhost';
	$user = 'root';
	$password = 'root';
	
	$link = mysql_connect($server, $user, $password);
	
	add_filter('the_content', 'showTables');

	function showTables($content) {
		$set = mysql_query('SHOW DATABASES;');
		$dbs = array();
		while($db = mysql_fetch_row($set))
		$dbs[] = $db[0];
		
		echo implode('<br/>', $dbs);
	}
?>

Danke für eure aufmerksamkeit

Modulentwicklung-Wordpress

By Daniel Scheich

Modulentwicklung-Wordpress

  • 148