easy footnotes 플러그인과 elementor 플러그인 함께 사용하기 (충돌 해결하기)

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on print
Print

워드프레스 포스팅에 주석을 달기 위해 easy footnotes 플러그인을 사용 중이다. 다른 주석 플러그인들을 모두 사용해본 건 아니지만 만족하면서 사용하고 있다. Easy Footnotes 플러그인을 Elementor 플러그인과 함께 사용하면 충돌이 발생한다.


Easy Footnotes와 Elementor 플러그인의 충돌

Elementor 플러그인을 이용해서 글을 편집하면 다음과 같은 문제가 발생한다.

  • 주석 번호가 1번부터 시작되지 않는다.
  • 글 하단에 주석 내용들이 중복되어 표현된다.
첫번째 주석이 5번부터 시작되는 것을 볼 수 있다.

문제의 원인

문제 원인을 Google에서 검색하다 다음의 문서를 발견했다.

Easy Footnotes는 the_content 훅을 이용해서 주석을 추가하는데, 하나의 페이지에서 the_content 훅에 추가한 function을 여러번 호출하는 것 같다는 얘기다. 아쉽게도 여기에 대한 해결방법은 적혀있지 않았다.


임시적인 해결방법 1

그래도 주석 하나 달아보겠다고 HTML 코딩을 직접할 수는 없는 노릇이다. 2

Elementor에 별도의 hook을 제공하지 않을 지 검색해보니 다음과 같이 자체적인 hook을 제공하는 것을 발견할 수 있었다.

저 중 elementor/frontend/the_content 훅이 워드프레스 기본 the_content 훅을 대체하는 용도라 예상하고, Easy Footnotes 플러그인의 easy-footnotes.php 파일을 다음과 같이 수정하니 주석이 제대로 동작하는 것을 확인할 수 있었다.

	/**
	 * Constructing the initial plugin options, shortcodes, and hooks.
	 */
	public function __construct() {
		$this->footnoteSettings = array(
			'footnoteLabel'                  => __( 'Footnotes', 'easy-footnotes' ),
			'useLabel'                       => false,
			'hide_easy_footnote_after_posts' => false,
			'show_easy_footnote_on_front'    => false,
		);

		add_option( 'easy_footnotes_options', $this->footnoteSettings );
		add_shortcode( 'note', array( $this, 'easy_footnote_shortcode' ) );
		add_shortcode( 'efn_note', array( $this, 'easy_footnote_shortcode' ) );
		add_filter( 'elementor/frontend/the_content', array( $this, 'easy_footnote_after_content' ), 20 );
		add_filter( 'elementor/frontend/the_content', array( $this, 'easy_footnote_reset' ), 999 );
		add_action( 'wp_enqueue_scripts', array( $this, 'register_qtip_scripts' ) );
		add_action( 'admin_menu', array( $this, 'easy_footnotes_admin_actions' ) );
		add_action( 'admin_enqueue_scripts', array( $this, 'easy_footnotes_admin_scripts' ) );

		$this->footnoteOptions = get_option( 'easy_footnotes_options' );
	}
주석 번호가 제대로 1번부터 나오는 것을 확인할 수 있다.

Easy Footnotes 플러그인의 동작 방식이나, Elementor의 Hook을 자세히 읽어보지 않았고, 어쩌다보니 문제가 해결되긴 했다. 다음에 시간 내서 분석해봐야 하겠다.


추가.. 위 방법은 잘 안된다. 차라리 플러그인을 새로 만들기로 했다.

처음에 되는 줄 알았는데, Elementor 기능들을 이것저것 사용하고, Section을 분리하니 잘 동작하지 않았다. 코드를 잠시 살펴 보았는데 차라리 새로 만드는 편이 쉬워 보여서 그냥 새로 만들기로 했다.

Footnotes

  1. 잘 되는 줄 알았는데, 안된다. 아래 추가글로 업데이트
  2. 플러그인 없이 주석을 달 수도 있기는 하다. https://www.templatemonster.com/blog/footnotes-wordpress/

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다