/* Plugin Name: Aphorismus Plugin URI: mailto:ovsyannikov.ivan@gmail.com Description: The plug-in allows to deduce the random text block (aphorism) on pages, posts or sidebar. Plugin have the widget. Version: 0.3.6 Author: Ivan Ovsyannikov Author URI: mailto:ovsyannikov.ivan@gmail.com */ global $wpdb; define('APHORISMUS_TABLE', $wpdb->prefix . 'aphorismus'); define('PLUGIN_NAME', 'aphorismus'); if (isset($_GET['action'])){ if ($_GET['action'] == 'export'){ require_once(dirname(__FILE__).'/includes/export.php'); aphorismus_export(); die(); } } register_activation_hook( __FILE__, 'aphorismus_setup' ); add_action('admin_menu', 'aphorismus_add_admin'); add_action('admin_head', 'aphorismus_admin_head'); /* add_action('admin_footer', 'aphorismus_admin_footer'); */ add_action('init', 'do_filter'); add_action('plugins_loaded', 'aphorismus_init'); function load_locale(){ $locale = get_locale(); if (empty($locale)) $locale = 'en_US'; $mofile = dirname( __FILE__ )."/locale/".$locale.".mo"; load_textdomain(PLUGIN_NAME, $mofile ); } function aphorismus_setup(){ global $wpdb; $create_table = "CREATE TABLE ".APHORISMUS_TABLE." (id int(11) NOT NULL auto_increment, text longtext NOT NULL, author varchar(255), primary key (id) );"; if($wpdb->get_var("SHOW TABLES LIKE '".APHORISMUS_TABLE."';") != APHORISMUS_TABLE){ require_once(ABSPATH.'wp-admin/upgrade-functions.php'); dbDelta($create_table); } update_option('aphorismus_template', '
%%text%%!
%%author%%!
\n";
echo "
\n";
echo "" . __ ('You can use HtMl–tegs. Constants:%%title%% — Deduces plug-in heading%%text%% — Deduces the aphorism text%%author%% — Deduces the author
The field «Author» is not obligatory for filling. Its conclusion should be surrounded by a symbol «!».', PLUGIN_NAME) . "\n";
echo "\n";
echo "
" . __ ('Aphorism added', PLUGIN_NAME) . "
" . __ ('Aphorism deleted', PLUGIN_NAME) . "
" . __ ('Aphorisms deleted', PLUGIN_NAME) . "
" . __ ('All aphorisms deleted', PLUGIN_NAME) . "
" . __ ('Settings saved', PLUGIN_NAME) . "
" . __ ('Aphorism saved', PLUGIN_NAME) . "
" . sprintf( __ ('Imported aphorisms: %d', PLUGIN_NAME), $aphorismus_importer->get_aphorismus_importer_count()) . "
The Aphorismus shows aphorisms on pages, in posts or on the sidebar. You can use
', PLUGIN_NAME) . "\n"; echo "%%aphorismus%%
\n"; echo __ ('for display in posts or on pages, or to use
', PLUGIN_NAME) . "\n"; echo "<?php aphorismus(); ?>
\n"; echo __ ('in templates.
At plugin activation, he automatically adds new widget. If in a template of your blog there is a sidebar, you can place on it widget. To make it it is possible in the management widget menu.
', PLUGIN_NAME) . "\n"; echo "aphorismus ( [ string \$arg ] [, int \$max_length ] )
\n"; echo __ ('aphorismus() echo string.
', PLUGIN_NAME) . "\n"; echo "get_aphorismus ( [ string \$arg ] [, int \$max_length ] )
\n"; echo __ ('get_aphorismus() return string.
', PLUGIN_NAME) . "\n"; echo __ ('arg values:
If the arg is empty or not set, function will deduce string with a output template.
', PLUGIN_NAME) . "\n"; echo __ ('max_length defines the maximum length of a deduced aphorism. By default is 0, thus the maximum length is not limited.
', PLUGIN_NAME) . "\n"; echo "" . get_aphorismus('notemplate', 200) . "