WordPress function to add text

As your hook only passes the $post_content and $attachment_id, you’ll first need to get the relevant post, and then you can output your required data. Please try this and comment if it does not meet your requirements. function myprefix_change_afip_post_content( $post_content, $attachment_id ) { global $post $post = get_post( $attachment_id ); setup_postdata( $post ); $my_uploaded_image = … Read more

Execute certain function on GET request

One of the earlier hooks that is aware of the page (I think) is load-{$slug}: add_action( ‘load-_my-plugin’, ‘wpse143915_maybe_trigger_export’ ); function wpse143915_maybe_trigger_export(){ if( isset( $_GET[‘export’] ) && ( $_GET[‘export’] == ‘data’ ) ){ //… } } If you want to find out what your page slug is, checkout this plug-in by Kaiser: https://github.com/franz-josef-kaiser/current-admin-info But personally, I … Read more

Allow user to input shortcode into wordpress widget

Very rough and partly cribbed from the Codex, but it should get you started: class My_SC_Widget extends WP_Widget { private $shortcodes = array( ‘sc1’ => ‘[sc1]’, ‘sc2’ => ‘[sc2]’, ‘sc3’ => ‘[sc3]’, ); function __construct() { // Instantiate the parent object parent::__construct( false, ‘My SC Widget’ ); } function widget( $args, $instance ) { if … Read more