wordpress

wordpress Contents and quick functions

http://codex.wordpress.org/Determining_Plugin_and_Content_Directories

Plugins
plugins_url()
plugin_dir_url()
plugin_dir_path()
plugin_basename()

Themes
get_template_directory_uri()
get_stylesheet_directory_uri()
get_stylesheet_uri()
get_theme_root_uri()
get_theme_root()
get_theme_roots()
get_stylesheet_directory()
get_template_directory()

Site Home
home_url()

WordPress

admin_url()
site_url()
content_url()
includes_url()
wp_upload_dir()

Multisite

get_admin_url()
get_home_url()
get_site_url()
network_admin_url()
network_site_url()
network_home_url()

Constants
WP_CONTENT_DIR // no trailing slash, full paths only
WP_CONTENT_URL // full url
WP_PLUGIN_DIR // full path, no trailing slash
WP_PLUGIN_URL // full url, no trailing slash

// Available per default in MS, not set in single site install
// Can be used in single site installs (as usual: at your own risk)
UPLOADS // uploads folder, relative to ABSPATH (for e.g.: /wp-content/uploads)

WordPress Directories:
home_url() Home URL http://www.example.com
site_url() Site directory URL http://www.example.com or http://www.example.com/wordpress
admin_url() Admin directory URL http://www.example.com/wp-admin
includes_url() Includes directory URL http://www.example.com/wp-includes
content_url() Content directory URL http://www.example.com/wp-content
plugins_url() Plugins directory URL http://www.example.com/wp-content/plugins
theme_url() Themes directory URL (#18302) http://www.example.com/wp-content/themes
wp_upload_dir() Upload directory URL (returns an array) http://www.example.com/wp-content/uploads

By bm on January 20, 2014 | wordpress | A comment?

wordpress constance

By bm on | wordpress | A comment?

wordpress constance

General

  • AUTOSAVE_INTERVAL #
    Defines an interval, in which WordPress should do an autosave.
    Value: time in seconds (Default: 60)
  • CORE_UPGRADE_SKIP_NEW_BUNDLED #
    Allows you to skip new bundles files like plugins and/or themes on upgrades.
    Values: true|false
  • DISABLE_WP_CRON #
    Deactivates the cron function of WordPress.
    Value: true
  • EMPTY_TRASH_DAYS #
    Controls the number of days before WordPress permanently deletes posts, pages, attachments, and comments, from the trash bin.
    Value: time in days (Default: 30)
  • IMAGE_EDIT_OVERWRITE #
    Allows WordPress to override an image after editing or to save the image as a copy.
    Values: true|false
  • MEDIA_TRASH #
    (De)activates the trash bin function for media.
    Values: true|false (Default: false)
  • WPLANG #
    Defines the language which WordPress should use.
    Values: For German de_DE
  • WP_DEFAULT_THEME #
    Defines a default theme for new sites, also used as fallback for a broken theme.
    Value: template name (Default: twentyeleven)
  • WP_CRON_LOCK_TIMEOUT #
    Defines a period of time in which only one cronjob will be fired. Since WordPress 3.3.
    Value: time in seconds (Default: 60)
  • WP_MAIL_INTERVAL #
    Defines a period of time in which only one mail request can be done.
    Value: time in seconds (Default: 300)
  • WP_POST_REVISIONS #
    (De)activates the revision function for posts. A number greater than 0 defines the number of revisions for one post.
    Values: true|false|number (Default: true)
  • WP_MAX_MEMORY_LIMIT #
    Allows you to change the maximum memory limit for some WordPress functions.
    Values: See PHP docs (Default: 256M)
  • WP_MEMORY_LIMIT #
    Defines the memory limit for WordPress.
    Values: See PHP docs (Default: 32M, for Multisite 64M)

Status

  • APP_REQUEST #
    Will be defined if it’s an Atom Publishing Protocol request.
    Value: true
  • COMMENTS_TEMPLATE #
    Will be defined if the comments template is loaded.
    Value: true
  • DOING_AJAX #
    Will be defined if it’s an AJAX request.
    Value: true
  • DOING_AUTOSAVE #
    Will be defined if WordPress is doing an autosave for posts.
    Value: true
  • DOING_CRON #
    Will be defined if WordPress is doing a cronjob.
    Value: true
  • IFRAME_REQUEST #
    Will be defined if it’s an inlineframe request.
    Value: true
  • IS_PROFILE_PAGE #
    Will be defined if a user change his profile settings.
    Value: true
  • SHORTINIT #
    Can be defined to load only the half of WordPress.
    Value: true
  • WP_ADMIN #
    Will be defined if it’s a request in backend of WordPress.
    Value: true
  • WP_BLOG_ADMIN #
    Will be defined if it’s a request in /wp-admin/.
    Value: true
  • WP_IMPORTING #
    Will be defined if WordPress is importing data.
    Value: true
  • WP_INSTALLING #
    Will be defined on an new installation or on an upgrade.
    Value: true
  • #WP_INSTALLING_NETWORK #
    Will be defined if it’s a request in network admin or on installing a network. Since WordPress 3.3, previous WP_NETWORK_ADMIN_PAGE.
    Value: true
  • WP_LOAD_IMPORTERS #
    Will be defined if you visit the importer overview (Tools → Importer).
    Value: true
  • WP_NETWORK_ADMIN #
    Will be defined if it’s a request in /wp-admin/network/.
    Value: true
  • WP_REPAIRING #
    Will be defined if it’s a request to /wp-admin/maint/repair.php.
    Value: true
  • WP_SETUP_CONFIG #
    Will be defined if WordPress will be installed or configured.
    Value: true
  • WP_UNINSTALL_PLUGIN #
    Will be defined if a plugin wil be uninstalled (for uninstall.php).
    Value: true
  • WP_USER_ADMIN #
    Will be defined if it’s a request in /wp-admin/user/.
    Value: true
  • XMLRPC_REQUEST #
    Will be defined if it’s a request over the XML-RPC API.
    Value: true

Paths, dirs and links

  • ABSPATH #
    Absolute path to the WordPress root dir.
    Default: path to wp-load.php
  • WPINC #
    Relative path to the /wp-includes/. You can’t change it.
    Default: wp-includes
  • WP_LANG_DIR #
    Absolute path to the folder with lanugage files.
    Default: WP_CONTENT_DIR /languages or WP_CONTENT_DIR WPINC /languages
  • WP_PLUGIN_DIR #
    Absolute path to the plugins dir.
    Default: WP_CONTENT_DIR /plugins
  • WP_PLUGIN_URL #
    URL to the plugins dir.
    Default: WP_CONTENT_URL /plugins
  • WP_CONTENT_DIR #
    Absolute path to thewp-content dir.
    Default: ABSPATH wp-content
  • WP_CONTENT_URL #
    URL to the wp-content dir.
    Default: {Site URL}/wp-content
  • WP_HOME #
    Home URL of your WordPress.
  • WP_SITEURL #
    URL to the WordPress root dir.
  • WP_TEMP_DIR #
    Absolute path to a dir, where temporary files can be saved.
  • WPMU_PLUGIN_DIR #
    Absolute path to the must use plugin dir.
    Default: WP_CONTENT_DIR /mu-plugins
  • WPMU_PLUGIN_URL #
    URL to the must use plugin dir.
    Default: WP_CONTENT_URL /mu-plugins

Database

  • DB_CHARSET #
    Defines the database charset.
    Values: See MySQL docs (Default: utf8)
  • DB_COLLATE #
    Defines the database collation.
    Values: See MySQL docs (Default: utf8_general_ci)
  • DB_HOST #
    Defines the database host.
    Values: IP address, domain and/or port (Default: localhost)
  • DB_NAME #
    Defines the database name.
    Value: database name
  • DB_PASSWORD #
    Defines the database password.
  • DB_USER #
    Defines the database user.
  • WP_ALLOW_REPAIR #
    Allows you to automatically repair and optimize the database tables via /wp-admin/maint/repair.php.
    Value: true
  • CUSTOM_USER_TABLE #
    Allows you to define a custom user table.
    Value: table name
  • CUSTOM_USER_META_TABLE #
    Allows you to define a custom user meta table.
    Value: table name

Multisite

  • ALLOW_SUBDIRECTORY_INSTALL #
    Allows you to install Multisite in a subdirectory.
    Value: true
  • BLOGUPLOADDIR #
    Absolute path to the site specific upload dir.
    Default: WP_CONTENT_DIR /blogs.dir/{Blog ID}/files/
  • BLOG_ID_CURRENT_SITE #
    Blog ID of the main site.
    Default: 1
  • DOMAIN_CURRENT_SITE #
    Domain of the main site.
    Default: domain
  • DIEONDBERROR #
    When defined database errors will be displayed on screen.
    Value: true
  • ERRORLOGFILE #
    When defined database erros will be logged into a file.
    Value: absolute path to a writeable file
  • MULTISITE #
    Will be defined if Multisite is used.
    Value: true
  • NOBLOGREDIRECT #
    Defines an URL of a site on which WordPress should redirect, if registration is closed or a site doesn’t exists.
    Values: %siteurl% for mainsite or custom URL
  • PATH_CURRENT_SITE #
    Path to the main site.
  • UPLOADBLOGSDIR #
    Path to the upload base dir, relative to ABSPATH.
    Default: wp-content/blogs.dir
  • SITE_ID_CURRENT_SITE #
    Network ID of the main site.
    Default: 1
  • SUBDOMAIN_INSTALL #
    Defines if it’s a subdomain install or not.
    Values: true|false
  • SUNRISE #
    When defined WordPres will load the /wp-content/sunrise.php file.
    Value: true
  • UPLOADS #
    Path to site specific upload dir, relative to ABSPATH.
    Default: UPLOADBLOGSDIR /{blogid}/files/
  • WPMU_ACCEL_REDIRECT #
    (De)activates support for X-Sendfile Header.
    Values: true|false (Default: false)
  • WPMU_SENDFILE #
    (De)activates support for X-Accel-Redirect Header.
    Values: true|false (Default: false)
  • WP_ALLOW_MULTISITE #
    When defined the multisite function will be accessible (Tools → Network Setup).
    Value: true

Cache and script compressing

  • WP_CACHE #
    When defined WordPres will load the /wp-content/advanced-cache.php file.
    Values: true|false (Default: false)
  • COMPRESS_CSS #
    (De)activates the compressing of stylesheets.
    Values: true|false
  • COMPRESS_SCRIPTS #
    (De)activates the compressing of Javascript files.
    Values: true|false
  • CONCATENATE_SCRIPTS #
    (De)activates the consolidation of Javascript or CSS files before compressing.
    Values: true|false
  • ENFORCE_GZIP #
    (De)activates gzip output.
    Values: true|false

Filesystem and connections

  • FS_CHMOD_DIR #
    Defines the read and write permissions for directories.
    Values: Siehe PHP Handbuch (Default: 0755)
  • FS_CHMOD_FILE #
    Defines the read and write permissions for files.
    Values: Siehe PHP Handbuch (Default: 0644)
  • FS_CONNECT_TIMEOUT #
    Defines a timeout for building a connection.
    Values: time in seconds (Default: 30)
  • FS_METHOD #
    Defines the method to connect to the filesystem.
    Values: direct|ssh|ftpext|ftpsockets
  • FS_TIMEOUT #
    Defines a timeout after a connection has been lost.
    Values: time in seconds (Default: 30)
  • FTP_BASE #
    Path to the WordPress root dir.
    Default: ABSPATH
  • FTP_CONTENT_DIR #
    Path to the /wp-content/ dir.
    Default: WP_CONTENT_DIR
  • FTP_HOST #
    Defines the FTP host.
    Values: IP Adresse, Domain und/oder Port
  • FTP_LANG_DIR #
    Path to the folder with language files.
    Default: WP_LANG_DIR
  • FTP_PASS #
    Defines the FTP password.
  • FTP_PLUGIN_DIR #
    Path to the plugin dir.
    Default: WP_PLUGIN_DIR
  • FTP_PRIKEY #
    Defines a private key for SSH.
  • FTP_PUBKEY #
    Defines a public key for SSH.
  • FTP_SSH #
    (De)activates SSH.
    Values: true|false
  • FTP_SSL #
    (De)activates SSL.
    Values: true|false
  • FTP_USER #
    Defines the FTP username.
  • WP_PROXY_BYPASS_HOSTS #
    Allows you to define some adresses which shouldn’t be passed through a proxy.
    Values: www.example.com, *.example.org
  • WP_PROXY_HOST #
    Defines the proxy adresse.
    Values: IP address or domain
  • WP_PROXY_PASSWORD #
    Defines the proxy password.
  • WP_PROXY_PORT #
    Defines the proxy port.
  • WP_PROXY_USERNAME #
    Defines the proxy username.
  • WP_HTTP_BLOCK_EXTERNAL #
    Allows you to block external request.
    Values: true|false
  • WP_ACCESSIBLE_HOSTS #
    If WP_HTTP_BLOCK_EXTERNAL is defined you can add hosts which shouldn’t be blocked.
    Values: www.example.com, *.example.org

Themes

  • BACKGROUND_IMAGE #
    Defines a default background image.
  • HEADER_IMAGE #
    Defines a default header image.
  • HEADER_IMAGE_HEIGHT #
    Defines the height of the header image.
  • HEADER_IMAGE_WIDTH #
    Defines the width of the header image.
  • HEADER_TEXTCOLOR #
    Defines the font color for the header text.
  • NO_HEADER_TEXT #
    (De)activates the support for header text.
    Values: true|false
  • STYLESHEETPATH #
    Defines the absolute path to the stylesheet of the current theme.
  • TEMPLATEPATH #
    Defines the absolute path to the template files of the current theme.
  • WP_USE_THEMES #
    (De)activates the loading of themes.
    Values: true|false

Debug

  • SAVEQUERIES #
    (De)activates the saving of database queries in an array ($wpdb->queries).
    Values: true|false
  • SCRIPT_DEBUG #
    (De)activates the loading of compressed Javascript and CSS files.
    Values: true|false
  • WP_DEBUG #
    (De)activates the debug mode in WordPress.
    Values: true|false (Default: false)
  • WP_DEBUG_DISPLAY #
    (De)activates the display of errors on the screen.
    Values: true|false|null (Default: true)
  • WP_DEBUG_LOG #
    (De)activates the writing of errors to the /wp-content/debug.log file.
    Values: true|false (Default: false)

Security and cookies

  • ALLOW_UNFILTERED_UPLOADS #
    Allows unfiltered uploads by admins.
    Value: true
  • AUTH_KEY #
    Secret key.
    Values: See generator
  • AUTH_SALT #
    Secret key.
    Values: See generator
  • COOKIEHASH #
    Hash for generating cookie names.
  • COOKIEPATH #
    Path to WordPress root dir.
    Default: Home URL without http(s)://
  • CUSTOM_TAGS #
    Allows you to override the list of secure HTML tags. See /wp-includes/kses.php.
    Values: true|false (Default: false)
  • DISALLOW_FILE_EDIT #
    Allows you to disallow theme and plugin edits via WordPress editor.
    Value: true
  • DISALLOW_FILE_MODS #
    Allows you to disallow the editing, updating, installing and deleting of plugins, themes and core files via WordPress Backend.
    Value: true
  • DISALLOW_UNFILTERED_HTML #
    Allows you to disallow unfiltered HTML for every user, admins too.
    Value: true
  • FORCE_SSL_ADMIN #
    Activates SSL for logins and in the backend.
    Values: true|false (Default: false)
  • FORCE_SSL_LOGIN #
    Activates SSL for logins.
    Values: true|false (Default: false)
  • LOGGED_IN_KEY #
    Secret key.
    Values: See generator
  • LOGGED_IN_SALT #
    Secret key.
    Values: See generator
  • NONCE_KEY #
    Secret key.
    Values: See generator
  • NONCE_SALT #
    Secret key.
    Values: See generator
  • SECURE_AUTH_KEY #
    Secret key.
    Values: See generator
  • SECURE_AUTH_SALT #
    Secret key.
    Values: See generator
  • SITECOOKIEPATH #
    Path of you site.
    Default: Site URL without http(s)://
By bm on | wordpress | A comment?

wordpress manualy upload files

<?php
if (! function_exists ( 'wp_handle_upload' ))
	require_once (ABSPATH . 'wp-admin/includes/file.php');

$uploadedfile = $_FILES ['myfile'];
$upload_overrides = array (
		'test_form' => false 
	);

//uploadm=ning file
$movefile = wp_handle_upload ( $uploadedfile, $upload_overrides );

if ($movefile) {

	//adding to media library
	$wp_filetype = $movefile ['type'];
	$filename = $movefile ['file'];
	$wp_upload_dir = wp_upload_dir ();

	$url = $wp_upload_dir ['url'] . '/' . basename ( $filename );
	$new_filename = basename ( $filename );

	$attachment = array (
			'guid' => $url,
			'post_mime_type' => $wp_filetype,
			'post_title' => preg_replace ( '/\.[^.]+$/', '', $new_filename ),
			'post_content' => '',
			'post_status' => 'inherit' 
	);

	$attach_id = wp_insert_attachment ( $attachment, $filename );

} else {
	//error uploading
}
?>
By bm on | wordpress | A comment?
Tags:

wordpress plugin trigger function while installing plugin

wordpress Plugin activation hook

class MyPlugin {
     static function install() {
     // do not generate any output here
     }
}
register_activation_hook( __FILE__, array( ‘MyPlugin’, ‘install’ ) );

http://codex.wordpress.org/Function_Reference/register_activation_hook

WordPress create HTML editor in page

<?php

$initcontent = '';
$editor_id = 'mycustomeditor';

wp_editor( $initcontent, $editor_id );

?>

Syntax

<?php 

wp_editor( $content, $editor_id, $settings = array() ); 

?>

 

Parameters

$content
(string) (required) Initial content for the editor.

Default: None
$editor_id
(string) (required) HTML id attribute value for the textarea and TinyMCE. (may only contain lower-case letters)

Default: None
$settings
(array) (optional) An array of arguments.

Default: array()

Arguments

wpautop
(boolean) (optional) Whether to use wpautop for adding in paragraphs

Default: true
media_buttons
(boolean) (optional) Whether to display media insert/upload buttons

Default: true
textarea_name
(string) (optional) The name assigned to the generated textarea and passed parameter when the form is submitted. (may include [] to pass data as array)

Default: $editor_id
textarea_rows
(integer) (optional) The number of rows to display for the textarea

Default: get_option('default_post_edit_rows', 10)
tabindex
(integer) (optional) The tabindex value used for the form field

Default: None
editor_css
(string) (optional) Additional CSS styling applied for both visual and HTML editors buttons, needs to include <style> tags, can use “scoped”

Default: None
editor_class
(string) (optional) Any extra CSS Classes to append to the Editor textarea

Default: Empty string
teeny
(boolean) (optional) Whether to output the minimal editor configuration used in PressThis

Default: false
dfw
(boolean) (optional) Whether to replace the default fullscreen editor with DFW (needs specific DOM elements and CSS)

Default: false
tinymce
(array) (optional) Load TinyMCE, can be used to pass settings directly to TinyMCE using an array

Default: true
quicktags
(array) (optional) Load Quicktags, can be used to pass settings directly to Quicktags using an array. Set to false to remove your editor’s Visual and Text tabs.

Default: true

Return Values

This function does not return a value.

 

By bm on January 16, 2014 | wordpress | A comment?
Tags: ,