-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpuentityadd.sh
80 lines (65 loc) · 2.15 KB
/
wpuentityadd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
echo '####';
echo '#### WPU Entity Add';
echo '#### v 0.42.0';
echo '####';
echo '';
###################################
## Config
###################################
MAINDIR="${PWD}/";
SOURCEDIR="$( dirname "${BASH_SOURCE[0]}" )/";
if [[ ! -f "${1}" ]];then
echo 'no valid file defined';
return 0;
fi;
_wpcontentdir=$(pwd);
wpcontent_dir=$(echo "${_wpcontentdir%/mu-plugins*}");
. "${SOURCEDIR}bin/functions.sh";
. "${SOURCEDIR}bin/detect.sh";
###################################
## Set values
###################################
mainfile="${1}";
project_prefix=$(basename "${mainfile}");
project_prefix=${project_prefix%_*};
# Check if post type
_has_post_type=$(search_extract_file "\$post_types\[\'" "\'\] \= array(" "${mainfile}")
_has_page=$(search_extract_file "\$pages_site\[\'" "__page_id\'\] = array(" "${mainfile}");
if [[ "${_has_post_type}" ]];then
entity_typename='entity';
entity_type='c';
entity_pluralid=${_has_post_type};
entity_id=${_has_post_type};
entity_name=$(search_extract_file "'name' => __('" "', '${project_prefix}')," "${mainfile}")
entity_plural=$(search_extract_file "'plural' => __('" "', '${project_prefix}')," "${mainfile}")
fi;
if [[ "${_has_page}" ]];then
entity_typename='page';
entity_type='p';
entity_pluralid="${_has_page}";
entity_id="${_has_page}";
entity_name=$(search_extract_file "'post_title' => '" "'," "${mainfile}");
entity_plural="${entity_name}";
fi;
# Page
if [[ $entity_type == 'p' ]]; then
. "${SOURCEDIR}bin/add_post_metas.sh";
. "${SOURCEDIR}bin/add_strates_page.sh";
. "${SOURCEDIR}bin/clean.sh";
fi;
# Custom post type
if [[ $entity_type == 'c' ]]; then
. "${SOURCEDIR}bin/add_options.sh";
. "${SOURCEDIR}bin/add_taxometas.sh";
. "${SOURCEDIR}bin/add_post_metas.sh";
. "${SOURCEDIR}bin/add_meta_box.sh";
. "${SOURCEDIR}bin/add_wpuseo.sh";
. "${SOURCEDIR}bin/add_pll.sh";
. "${SOURCEDIR}bin/add_to_blocks.sh";
. "${SOURCEDIR}bin/add_filters.sh";
. "${SOURCEDIR}bin/add_archive_acf_fields.sh";
. "${SOURCEDIR}bin/add_admin_columns.sh";
. "${SOURCEDIR}bin/add_fixtures.sh";
. "${SOURCEDIR}bin/clean.sh";
fi;