Giter Site home page Giter Site logo

wp-media-license's Introduction

Media License

Allows you to add media license info to your media files. Plugin is available at WordPress.org

Captions are automatically added to images in post content. Elsewhere you can use media_license_get_caption function.

Templates

You can copy the default templates from plugins "templates" folder to "%theme%/plugin-parts/*".

media-license-caption.tpl.php

Available variables in template:

$this ===> MediaLicense object context.

$caption ===> Image caption text.

$original_caption ===> Unmanipulated caption text. (No manipulations from other plugins)

$license ===> MediaLicense\CreativeCommon object

$info ===> Array of meta information. (author, info, url, all additional from add_fields filter)

$media_license_author ===> Author field text.

$media_license_info ===> License info text.

$media_license_url ===> License url.


Filters

Available filters for media license plugin.

Mainupate caption text

add_filter( 'media_license_edit_caption', 'myplugin_media_license_edit_caption', 10, 3);
function myplugin_media_license_edit_caption($caption, $original_caption, $info){
	// manipulate $caption
	return $caption;
}

Parameters:

$caption ==> The manipulated caption.

$caption_original ==> The unmanipulated caption.

$info ==> Array of info field values.

Return

manipulated_caption ===> Manipulate the $caption and return the result

Add even more info fields

add_filter( 'media_license_add_fields', 'myplugin_media_license_add_fields');
function myplugin_media_license_add_fields($fields){
	// manipulate $fields
	return $fields;
}

Parameters:

$fields ==> Array of field definitions.

Available Types:

$fields['my_text_field'] = array(
	'label' => 'Field label',
	'input' => 'text',
	'value' => 'default value',
	'helps' => 'Descriptive text',
);

$fields['my_select_field'] = array(
    'label' => 'Field label',
    'input' => 'select',
    'value' => '',
    'helps' => 'Descriptive text',
    'selections' => array(
        array(
            "value" => 'slug1',
            "label" => 'Label 1',
        ),
        ...
    ),
);

Functions

Public plugin function. Always use php function_exists(...) before using an function.

Get license caption by attachment ID

$caption = media_license_get_caption($attachment_id)

Parameters:

$attachment_id ==> ID of the attachment.

Return

caption ===> rendered caption.

wp-media-license's People

Contributors

edwardbock avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.