<?php

namespace Reach\App;

use Reach\App\Interfaces\WordPressHooks;

/**
 * Class Sharing
 *
 * @package Reach\App
 */
class Sharing implements WordPressHooks {

    /**
     * Add class hooks.
     */
    public function addHooks() {
        add_filter( 'addthis_sharing_buttons_above_enable', [ $this, 'removeModuleShareButtons' ] );
        add_filter( 'addthis_sharing_buttons_below_enable', [ $this, 'removeModuleShareButtons' ] );
    }

    /**
     * Determines if we are in a module and prevents share button output.
     *
     * @param $filter
     *
     * @return bool
     */
    public function removeModuleShareButtons( $filter ) {
        if ( doing_action( 'reach/modules/output' ) ) {
            // remove the share button when doing module output
            return false;
        }

        return $filter;
    }

}
