Site icon Hip-Hop Website Design and Development

Use motion, filter, or hook to append HTML to WordPress plugin perform

I’m new to WordPress actions, filters, and hooks, and am questioning whether it is doable to make use of one of many three to append some HTML to an outlined plugin perform utilizing the theme’s capabilities.php file. The HTML is helper textual content that’s at the moment within the plugin’s essential PHP file, however would I like to maneuver it to the capabilities.php file due to future updates to the plugin. The paragraph with the category of “appended-text” is what ought to be appended to the HTML utilizing an motion, filter, or hook.

Plugin’s perform:

public perform insert_upload_form() {
    if ( ! current_user_can( 'upload_files' ) ) {
        return; //Customers have to be writer or larger
    }

$user_id = $this->get_user_id();
$post_id = $this->get_post_id( $user_id );

?>
<tr valign="prime" class="user-metronet-profile-picture">
    <th scope="row"><?php esc_html_e( 'Profile Picture', 'metronet-profile-picture' ); ?></th>
    <td id="mpp">
        <enter sort="hidden" title="metronet_profile_id" id="metronet_profile_id" worth="<?php echo esc_attr( $user_id ); ?>" />
        <enter sort="hidden" title="metronet_post_id" id="metronet_post_id" worth="<?php echo esc_attr( $post_id ); ?>" />
        <div id="metronet-profile-image">
        <?php
        $has_profile_image = false;
        if ( has_post_thumbnail( $post_id ) ) {
            $has_profile_image = true;
            echo '<a mode="show:block" href="#" class="mpp_add_media">';
            $thumb_src      = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'thumbnail', false, '' );
            $post_thumbnail = sprintf( '<img type="show:block" src="%s" width="150" top="150" title="%s" />', esc_url( $thumb_src[0] ), esc_attr__( 'Add or Change Profile Image', 'metronet-profile-picture' ) );
            echo wp_kses_post( $post_thumbnail );
            echo sprintf( '<div id="metronet-click-edit">%s</div>', esc_html__( 'Click on to Edit', 'metronet-profile-picture' ) );
            echo '</a>';
        } else {
            echo '<a mode="show:block" href="#" class="mpp_add_media default-image">';
            $post_thumbnail = sprintf( '<img type="show:block" src="%s" width="150" top="150" title="%s" />', self::get_plugin_url( 'img/thriller.png' ), esc_attr__( 'Add or Change Profile Image', 'metronet-profile-picture' ) );
            echo wp_kses_post( $post_thumbnail );
            echo sprintf( '<div id="metronet-click-edit">%s</div>', esc_html__( 'Click on to Edit', 'metronet-profile-picture' ) );
            echo '</a>';
        }
        $remove_classes = array( 'dashicons', 'dashicons-trash' );
        if ( ! $has_profile_image ) {
            $remove_classes[] = 'mpp-no-profile-image';
        }
        ?>
            <a id="metronet-remove" class="<?php echo implode( ' ', $remove_classes ); // phpcs:ignore ?>" href="#" title="<?php esc_attr_e( 'Take away profile picture', 'metronet-profile-picture' ); ?>"><?php esc_html_e( 'Take away profile picture', 'metronet-profile-picture' ); ?></a>
            <div type="show: none">
                <?php printf( '<img class="mpp-loading" width="150" top="150" alt="Loading" src="%s" />', esc_url( self::get_plugin_url( '/img/loading.gif' ) ) ); ?>
            </div>
        </div><!-- #metronet-profile-image -->
        <div id="metronet-override-avatar">
            <enter sort="hidden" title="metronet-user-avatar" worth="off" />
            <?php
            //Get the person avatar override choice - If not set, see if there is a filter override.
            $user_avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
            $checked = '';
            if ( $user_avatar_override ) {
                $checked = checked( 'on', $user_avatar_override, false );
            } else {
                $checked = checked( true, apply_filters( 'mpp_avatar_override', false ), false );
            }

            //Filter for hiding the override interface.  If this feature is about to true, the mpp_avatar_override filter is ignored and override is enabled by default
            $hide_override = apply_filters( 'mpp_hide_avatar_override', false );
            if ( $hide_override ) :
                ?>
                <enter sort="hidden" title="metronet-user-avatar" id="metronet-user-avatar" worth="on"  />
                <?php
                else :
                    ?>
                    <br /><enter sort="checkbox" title="metronet-user-avatar" id="metronet-user-avatar" worth="on" <?php echo $checked; // phpcs:ignore ?> /> <label for="metronet-user-avatar"><?php esc_html_e( 'Override Avatar?', 'metronet-profile-picture' ); ?></label>
                <?php endif; ?>
        </div><!-- #metronet-override-avatar -->
        <p class="appended-text">
            <sturdy>Be aware: optimum picture measurement is 200 pixels huge by 200 pixels tall.<br>
            Most file measurement is 200KB.<br>
            (Your profile picture might seem "squished" on this preview, however will seem regular on articles and occasions you put up, and in your writer web page.)
            </sturdy>
        </p>
    </td>
</tr>
<?php
/**
 * Permit different plugins to run code after the person profile image UI.
 *
 * @since 2.3.0
 *
 */
do_action( 'mpp_user_profile_form', $user_id );
} //finish insert_upload_form