ec91ad78 by Jeff Balicki

create product

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent c3e9dd24
Showing 70 changed files with 9355 additions and 0 deletions
...@@ -1883,3 +1883,195 @@ ...@@ -1883,3 +1883,195 @@
1883 INFO [7c00f1aa] Finished in 0.203 seconds with exit status 0 (successful). 1883 INFO [7c00f1aa] Finished in 0.203 seconds with exit status 0 (successful).
1884 INFO [3a026d41] Running si crlg-staging as tenzing_www@web-1 1884 INFO [3a026d41] Running si crlg-staging as tenzing_www@web-1
1885 INFO [3a026d41] Finished in 2.232 seconds with exit status 0 (successful). 1885 INFO [3a026d41] Finished in 2.232 seconds with exit status 0 (successful).
1886 INFO ---------------------------------------------------------------------------
1887 INFO START 2023-02-09 19:22:00 -0500 cap staging deploy
1888 INFO ---------------------------------------------------------------------------
1889 INFO [0a367bfe] Running /usr/bin/env mkdir -p /tmp as tenzing_www@web-1
1890 INFO [0a367bfe] Finished in 1.449 seconds with exit status 0 (successful).
1891 INFO Uploading /tmp/git-ssh-crlg-staging-staging-jeffbalicki.sh 100.0%
1892 INFO [9856fb79] Running /usr/bin/env chmod 700 /tmp/git-ssh-crlg-staging-staging-jeffbalicki.sh as tenzing_www@web-1
1893 INFO [9856fb79] Finished in 0.231 seconds with exit status 0 (successful).
1894 INFO [61f2cc32] Running /usr/bin/env git ls-remote git@git.gotenzing.com:jeffmbalicki/st_joseph.git HEAD as tenzing_www@web-1
1895 INFO [61f2cc32] Finished in 0.949 seconds with exit status 0 (successful).
1896 INFO [1c12df78] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared /var/www/html/production/crlg-staging/releases as tenzing_www@web-1
1897 INFO [1c12df78] Finished in 0.229 seconds with exit status 0 (successful).
1898 INFO [1b67be8e] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared/wp-content/wflogs /var/www/html/production/crlg-staging/shared/wp-content/uploads /var/www/html/production/crlg-staging/shared/wp-content/storage /var/www/html/production/crlg-staging/shared/wp-content/languages /var/www/html/production/crlg-staging/shared/wp-content/cache /var/www/html/production/crlg-staging/shared/wp-content/wp-rocket-config as tenzing_www@web-1
1899 INFO [1b67be8e] Finished in 0.234 seconds with exit status 0 (successful).
1900 INFO [bc7f6321] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared as tenzing_www@web-1
1901 INFO [bc7f6321] Finished in 0.214 seconds with exit status 0 (successful).
1902 INFO The repository mirror is at /var/www/html/production/crlg-staging/repo
1903 INFO [e622611a] Running /usr/bin/env git remote set-url origin git@git.gotenzing.com:jeffmbalicki/st_joseph.git as tenzing_www@web-1
1904 INFO [e622611a] Finished in 0.214 seconds with exit status 0 (successful).
1905 INFO [5ef6cda3] Running /usr/bin/env git remote update --prune as tenzing_www@web-1
1906 INFO [5ef6cda3] Finished in 1.358 seconds with exit status 0 (successful).
1907 INFO [6a852bb6] Running /usr/bin/env git clone -b master --recursive . /var/www/html/production/crlg-staging/releases/20230210002205 as tenzing_www@web-1
1908 INFO [6a852bb6] Finished in 4.505 seconds with exit status 0 (successful).
1909 INFO [20c79c74] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210002205 as tenzing_www@web-1
1910 INFO [20c79c74] Finished in 0.217 seconds with exit status 0 (successful).
1911 INFO [99c252f9] Running /usr/bin/env git archive master | /usr/bin/env tar -x -f - -C /var/www/html/production/crlg-staging/releases/20230210002205 as tenzing_www@web-1
1912 INFO [99c252f9] Finished in 3.290 seconds with exit status 0 (successful).
1913 INFO [5006bfd8] Running /usr/bin/env echo "24a7e393deac85dab4f34fb070835b64189433e2" >> REVISION as tenzing_www@web-1
1914 INFO [5006bfd8] Finished in 0.211 seconds with exit status 0 (successful).
1915 INFO [b988e297] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210002205 as tenzing_www@web-1
1916 INFO [b988e297] Finished in 0.206 seconds with exit status 0 (successful).
1917 INFO [e22fd090] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/.env /var/www/html/production/crlg-staging/releases/20230210002205/.env as tenzing_www@web-1
1918 INFO [e22fd090] Finished in 0.207 seconds with exit status 0 (successful).
1919 INFO [7501d791] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210002205/wp-content as tenzing_www@web-1
1920 INFO [7501d791] Finished in 0.210 seconds with exit status 0 (successful).
1921 INFO [d016cfe8] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/wflogs /var/www/html/production/crlg-staging/releases/20230210002205/wp-content/wflogs as tenzing_www@web-1
1922 INFO [d016cfe8] Finished in 0.229 seconds with exit status 0 (successful).
1923 INFO [1892fdc2] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/uploads /var/www/html/production/crlg-staging/releases/20230210002205/wp-content/uploads as tenzing_www@web-1
1924 INFO [1892fdc2] Finished in 0.206 seconds with exit status 0 (successful).
1925 INFO [e04c27a6] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/storage /var/www/html/production/crlg-staging/releases/20230210002205/wp-content/storage as tenzing_www@web-1
1926 INFO [e04c27a6] Finished in 0.216 seconds with exit status 0 (successful).
1927 INFO [c4152b74] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/languages /var/www/html/production/crlg-staging/releases/20230210002205/wp-content/languages as tenzing_www@web-1
1928 INFO [c4152b74] Finished in 0.215 seconds with exit status 0 (successful).
1929 INFO [6010e9f3] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/cache /var/www/html/production/crlg-staging/releases/20230210002205/wp-content/cache as tenzing_www@web-1
1930 INFO [6010e9f3] Finished in 0.218 seconds with exit status 0 (successful).
1931 INFO [cc50bd49] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/wp-rocket-config /var/www/html/production/crlg-staging/releases/20230210002205/wp-content/wp-rocket-config as tenzing_www@web-1
1932 INFO [cc50bd49] Finished in 0.207 seconds with exit status 0 (successful).
1933 INFO [7dd39256] Running cd '/var/www/html/production/crlg-staging/releases/20230210002205'; /usr/bin/php73 /home/tenzing_www/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as tenzing_www@web-1
1934 INFO [7dd39256] Finished in 1.059 seconds with exit status 0 (successful).
1935 INFO [7c88c448] Running si crlg-staging as tenzing_www@web-1
1936 INFO [7c88c448] Finished in 9.214 seconds with exit status 0 (successful).
1937 INFO [2278610c] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/releases/20230210002205 /var/www/html/production/crlg-staging/releases/current as tenzing_www@web-1
1938 INFO [2278610c] Finished in 0.438 seconds with exit status 0 (successful).
1939 INFO [e1da1f6f] Running /usr/bin/env mv /var/www/html/production/crlg-staging/releases/current /var/www/html/production/crlg-staging as tenzing_www@web-1
1940 INFO [e1da1f6f] Finished in 0.206 seconds with exit status 0 (successful).
1941 INFO Keeping 2 of 3 deployed releases on web-1
1942 INFO [12512cbc] Running /usr/bin/env rm -rf /var/www/html/production/crlg-staging/releases/20230209211230 as tenzing_www@web-1
1943 INFO [12512cbc] Finished in 0.727 seconds with exit status 0 (successful).
1944 INFO [83ff0362] Running cd '/var/www/html/production/crlg-staging/releases/20230210002205/'; rm -Rf .git/ as tenzing_www@web-1
1945 INFO [83ff0362] Finished in 0.223 seconds with exit status 0 (successful).
1946 INFO [e789176f] Running /usr/bin/env echo "Branch master (at 24a7e393deac85dab4f34fb070835b64189433e2) deployed as release 20230210002205 by jeffbalicki" >> /var/www/html/production/crlg-staging/revisions.log as tenzing_www@web-1
1947 INFO [e789176f] Finished in 0.211 seconds with exit status 0 (successful).
1948 INFO [0230273f] Running si crlg-staging as tenzing_www@web-1
1949 INFO [0230273f] Finished in 2.465 seconds with exit status 0 (successful).
1950 INFO ---------------------------------------------------------------------------
1951 INFO START 2023-02-09 19:34:38 -0500 cap staging deploy
1952 INFO ---------------------------------------------------------------------------
1953 INFO [dd5f8c89] Running /usr/bin/env mkdir -p /tmp as tenzing_www@web-1
1954 INFO [dd5f8c89] Finished in 1.387 seconds with exit status 0 (successful).
1955 INFO Uploading /tmp/git-ssh-crlg-staging-staging-jeffbalicki.sh 100.0%
1956 INFO [ddb6b26e] Running /usr/bin/env chmod 700 /tmp/git-ssh-crlg-staging-staging-jeffbalicki.sh as tenzing_www@web-1
1957 INFO [ddb6b26e] Finished in 0.255 seconds with exit status 0 (successful).
1958 INFO [58d9977d] Running /usr/bin/env git ls-remote git@git.gotenzing.com:jeffmbalicki/st_joseph.git HEAD as tenzing_www@web-1
1959 INFO [58d9977d] Finished in 0.971 seconds with exit status 0 (successful).
1960 INFO [77b381d4] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared /var/www/html/production/crlg-staging/releases as tenzing_www@web-1
1961 INFO [77b381d4] Finished in 0.248 seconds with exit status 0 (successful).
1962 INFO [b44b8d1b] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared/wp-content/wflogs /var/www/html/production/crlg-staging/shared/wp-content/uploads /var/www/html/production/crlg-staging/shared/wp-content/storage /var/www/html/production/crlg-staging/shared/wp-content/languages /var/www/html/production/crlg-staging/shared/wp-content/cache /var/www/html/production/crlg-staging/shared/wp-content/wp-rocket-config as tenzing_www@web-1
1963 INFO [b44b8d1b] Finished in 0.247 seconds with exit status 0 (successful).
1964 INFO [b752fe06] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared as tenzing_www@web-1
1965 INFO [b752fe06] Finished in 0.257 seconds with exit status 0 (successful).
1966 INFO The repository mirror is at /var/www/html/production/crlg-staging/repo
1967 INFO [455a4528] Running /usr/bin/env git remote set-url origin git@git.gotenzing.com:jeffmbalicki/st_joseph.git as tenzing_www@web-1
1968 INFO [455a4528] Finished in 0.260 seconds with exit status 0 (successful).
1969 INFO [4a56128e] Running /usr/bin/env git remote update --prune as tenzing_www@web-1
1970 INFO [4a56128e] Finished in 1.035 seconds with exit status 0 (successful).
1971 INFO [b62d6017] Running /usr/bin/env git clone -b master --recursive . /var/www/html/production/crlg-staging/releases/20230210003442 as tenzing_www@web-1
1972 INFO [b62d6017] Finished in 2.952 seconds with exit status 0 (successful).
1973 INFO [c5f350c1] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210003442 as tenzing_www@web-1
1974 INFO [c5f350c1] Finished in 0.267 seconds with exit status 0 (successful).
1975 INFO [8f803513] Running /usr/bin/env git archive master | /usr/bin/env tar -x -f - -C /var/www/html/production/crlg-staging/releases/20230210003442 as tenzing_www@web-1
1976 INFO [8f803513] Finished in 3.545 seconds with exit status 0 (successful).
1977 INFO [299a54f5] Running /usr/bin/env echo "24a7e393deac85dab4f34fb070835b64189433e2" >> REVISION as tenzing_www@web-1
1978 INFO [299a54f5] Finished in 0.260 seconds with exit status 0 (successful).
1979 INFO [e1e5ce07] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210003442 as tenzing_www@web-1
1980 INFO [e1e5ce07] Finished in 0.256 seconds with exit status 0 (successful).
1981 INFO [46e937c1] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/.env /var/www/html/production/crlg-staging/releases/20230210003442/.env as tenzing_www@web-1
1982 INFO [46e937c1] Finished in 0.247 seconds with exit status 0 (successful).
1983 INFO [65f0114b] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210003442/wp-content as tenzing_www@web-1
1984 INFO [65f0114b] Finished in 0.245 seconds with exit status 0 (successful).
1985 INFO [fbca6af9] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/wflogs /var/www/html/production/crlg-staging/releases/20230210003442/wp-content/wflogs as tenzing_www@web-1
1986 INFO [fbca6af9] Finished in 0.250 seconds with exit status 0 (successful).
1987 INFO [e2833818] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/uploads /var/www/html/production/crlg-staging/releases/20230210003442/wp-content/uploads as tenzing_www@web-1
1988 INFO [e2833818] Finished in 0.250 seconds with exit status 0 (successful).
1989 INFO [47ac3081] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/storage /var/www/html/production/crlg-staging/releases/20230210003442/wp-content/storage as tenzing_www@web-1
1990 INFO [47ac3081] Finished in 0.261 seconds with exit status 0 (successful).
1991 INFO [475beb05] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/languages /var/www/html/production/crlg-staging/releases/20230210003442/wp-content/languages as tenzing_www@web-1
1992 INFO [475beb05] Finished in 0.278 seconds with exit status 0 (successful).
1993 INFO [4ec90508] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/cache /var/www/html/production/crlg-staging/releases/20230210003442/wp-content/cache as tenzing_www@web-1
1994 INFO [4ec90508] Finished in 0.245 seconds with exit status 0 (successful).
1995 INFO [1f79e7c4] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/wp-rocket-config /var/www/html/production/crlg-staging/releases/20230210003442/wp-content/wp-rocket-config as tenzing_www@web-1
1996 INFO [1f79e7c4] Finished in 0.247 seconds with exit status 0 (successful).
1997 INFO [07a7446c] Running cd '/var/www/html/production/crlg-staging/releases/20230210003442'; /usr/bin/php73 /home/tenzing_www/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as tenzing_www@web-1
1998 INFO [07a7446c] Finished in 1.080 seconds with exit status 0 (successful).
1999 INFO [39be5161] Running si crlg-staging as tenzing_www@web-1
2000 INFO [39be5161] Finished in 13.924 seconds with exit status 0 (successful).
2001 INFO [03453718] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/releases/20230210003442 /var/www/html/production/crlg-staging/releases/current as tenzing_www@web-1
2002 INFO [03453718] Finished in 0.390 seconds with exit status 0 (successful).
2003 INFO [56f754e4] Running /usr/bin/env mv /var/www/html/production/crlg-staging/releases/current /var/www/html/production/crlg-staging as tenzing_www@web-1
2004 INFO [56f754e4] Finished in 0.247 seconds with exit status 0 (successful).
2005 INFO Keeping 2 of 3 deployed releases on web-1
2006 INFO [88897a5f] Running /usr/bin/env rm -rf /var/www/html/production/crlg-staging/releases/20230209221055 as tenzing_www@web-1
2007 INFO [88897a5f] Finished in 0.853 seconds with exit status 0 (successful).
2008 INFO [744b21d8] Running cd '/var/www/html/production/crlg-staging/releases/20230210003442/'; rm -Rf .git/ as tenzing_www@web-1
2009 INFO [744b21d8] Finished in 0.268 seconds with exit status 0 (successful).
2010 INFO [ab55c45e] Running /usr/bin/env echo "Branch master (at 24a7e393deac85dab4f34fb070835b64189433e2) deployed as release 20230210003442 by jeffbalicki" >> /var/www/html/production/crlg-staging/revisions.log as tenzing_www@web-1
2011 INFO [ab55c45e] Finished in 0.251 seconds with exit status 0 (successful).
2012 INFO [86034fd4] Running si crlg-staging as tenzing_www@web-1
2013 INFO [86034fd4] Finished in 2.516 seconds with exit status 0 (successful).
2014 INFO ---------------------------------------------------------------------------
2015 INFO START 2023-02-09 19:45:15 -0500 cap staging deploy
2016 INFO ---------------------------------------------------------------------------
2017 INFO [7ca0b311] Running /usr/bin/env mkdir -p /tmp as tenzing_www@web-1
2018 INFO [7ca0b311] Finished in 1.315 seconds with exit status 0 (successful).
2019 INFO Uploading /tmp/git-ssh-crlg-staging-staging-jeffbalicki.sh 100.0%
2020 INFO [43cbd4c1] Running /usr/bin/env chmod 700 /tmp/git-ssh-crlg-staging-staging-jeffbalicki.sh as tenzing_www@web-1
2021 INFO [43cbd4c1] Finished in 0.220 seconds with exit status 0 (successful).
2022 INFO [29e5366b] Running /usr/bin/env git ls-remote git@git.gotenzing.com:jeffmbalicki/st_joseph.git HEAD as tenzing_www@web-1
2023 INFO [29e5366b] Finished in 0.925 seconds with exit status 0 (successful).
2024 INFO [342135b5] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared /var/www/html/production/crlg-staging/releases as tenzing_www@web-1
2025 INFO [342135b5] Finished in 0.225 seconds with exit status 0 (successful).
2026 INFO [d9ba6d70] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared/wp-content/wflogs /var/www/html/production/crlg-staging/shared/wp-content/uploads /var/www/html/production/crlg-staging/shared/wp-content/storage /var/www/html/production/crlg-staging/shared/wp-content/languages /var/www/html/production/crlg-staging/shared/wp-content/cache /var/www/html/production/crlg-staging/shared/wp-content/wp-rocket-config as tenzing_www@web-1
2027 INFO [d9ba6d70] Finished in 0.222 seconds with exit status 0 (successful).
2028 INFO [106331b4] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/shared as tenzing_www@web-1
2029 INFO [106331b4] Finished in 0.211 seconds with exit status 0 (successful).
2030 INFO The repository mirror is at /var/www/html/production/crlg-staging/repo
2031 INFO [3aaf498e] Running /usr/bin/env git remote set-url origin git@git.gotenzing.com:jeffmbalicki/st_joseph.git as tenzing_www@web-1
2032 INFO [3aaf498e] Finished in 0.214 seconds with exit status 0 (successful).
2033 INFO [51380cfc] Running /usr/bin/env git remote update --prune as tenzing_www@web-1
2034 INFO [51380cfc] Finished in 1.064 seconds with exit status 0 (successful).
2035 INFO [47953396] Running /usr/bin/env git clone -b master --recursive . /var/www/html/production/crlg-staging/releases/20230210004519 as tenzing_www@web-1
2036 INFO [47953396] Finished in 3.199 seconds with exit status 0 (successful).
2037 INFO [708596e9] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210004519 as tenzing_www@web-1
2038 INFO [708596e9] Finished in 0.223 seconds with exit status 0 (successful).
2039 INFO [9dd49d83] Running /usr/bin/env git archive master | /usr/bin/env tar -x -f - -C /var/www/html/production/crlg-staging/releases/20230210004519 as tenzing_www@web-1
2040 INFO [9dd49d83] Finished in 3.626 seconds with exit status 0 (successful).
2041 INFO [295d92ac] Running /usr/bin/env echo "c3e9dd24904455e24d6695ed50a1d8cfce782b8b" >> REVISION as tenzing_www@web-1
2042 INFO [295d92ac] Finished in 0.208 seconds with exit status 0 (successful).
2043 INFO [852e3cc7] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210004519 as tenzing_www@web-1
2044 INFO [852e3cc7] Finished in 0.212 seconds with exit status 0 (successful).
2045 INFO [a9736fcd] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/.env /var/www/html/production/crlg-staging/releases/20230210004519/.env as tenzing_www@web-1
2046 INFO [a9736fcd] Finished in 0.214 seconds with exit status 0 (successful).
2047 INFO [31994e43] Running /usr/bin/env mkdir -p /var/www/html/production/crlg-staging/releases/20230210004519/wp-content as tenzing_www@web-1
2048 INFO [31994e43] Finished in 0.228 seconds with exit status 0 (successful).
2049 INFO [2513f838] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/wflogs /var/www/html/production/crlg-staging/releases/20230210004519/wp-content/wflogs as tenzing_www@web-1
2050 INFO [2513f838] Finished in 0.231 seconds with exit status 0 (successful).
2051 INFO [ded24eb0] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/uploads /var/www/html/production/crlg-staging/releases/20230210004519/wp-content/uploads as tenzing_www@web-1
2052 INFO [ded24eb0] Finished in 0.209 seconds with exit status 0 (successful).
2053 INFO [6f3722d2] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/storage /var/www/html/production/crlg-staging/releases/20230210004519/wp-content/storage as tenzing_www@web-1
2054 INFO [6f3722d2] Finished in 0.210 seconds with exit status 0 (successful).
2055 INFO [176adf88] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/languages /var/www/html/production/crlg-staging/releases/20230210004519/wp-content/languages as tenzing_www@web-1
2056 INFO [176adf88] Finished in 0.208 seconds with exit status 0 (successful).
2057 INFO [b6f27d34] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/cache /var/www/html/production/crlg-staging/releases/20230210004519/wp-content/cache as tenzing_www@web-1
2058 INFO [b6f27d34] Finished in 0.209 seconds with exit status 0 (successful).
2059 INFO [f4a125a8] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/shared/wp-content/wp-rocket-config /var/www/html/production/crlg-staging/releases/20230210004519/wp-content/wp-rocket-config as tenzing_www@web-1
2060 INFO [f4a125a8] Finished in 0.207 seconds with exit status 0 (successful).
2061 INFO [5ed704c4] Running cd '/var/www/html/production/crlg-staging/releases/20230210004519'; /usr/bin/php73 /home/tenzing_www/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as tenzing_www@web-1
2062 INFO [5ed704c4] Finished in 0.910 seconds with exit status 0 (successful).
2063 INFO [b4e0dac6] Running si crlg-staging as tenzing_www@web-1
2064 INFO [b4e0dac6] Finished in 6.346 seconds with exit status 0 (successful).
2065 INFO [a2fe07fb] Running /usr/bin/env ln -s /var/www/html/production/crlg-staging/releases/20230210004519 /var/www/html/production/crlg-staging/releases/current as tenzing_www@web-1
2066 INFO [a2fe07fb] Finished in 0.525 seconds with exit status 0 (successful).
2067 INFO [d69ecd68] Running /usr/bin/env mv /var/www/html/production/crlg-staging/releases/current /var/www/html/production/crlg-staging as tenzing_www@web-1
2068 INFO [d69ecd68] Finished in 0.222 seconds with exit status 0 (successful).
2069 INFO Keeping 2 of 3 deployed releases on web-1
2070 INFO [a25b28f3] Running /usr/bin/env rm -rf /var/www/html/production/crlg-staging/releases/20230210002205 as tenzing_www@web-1
2071 INFO [a25b28f3] Finished in 0.976 seconds with exit status 0 (successful).
2072 INFO [ea6a8ba2] Running cd '/var/www/html/production/crlg-staging/releases/20230210004519/'; rm -Rf .git/ as tenzing_www@web-1
2073 INFO [ea6a8ba2] Finished in 0.237 seconds with exit status 0 (successful).
2074 INFO [1ac260f6] Running /usr/bin/env echo "Branch master (at c3e9dd24904455e24d6695ed50a1d8cfce782b8b) deployed as release 20230210004519 by jeffbalicki" >> /var/www/html/production/crlg-staging/revisions.log as tenzing_www@web-1
2075 INFO [1ac260f6] Finished in 0.206 seconds with exit status 0 (successful).
2076 INFO [f13ca3fd] Running si crlg-staging as tenzing_www@web-1
2077 INFO [f13ca3fd] Finished in 2.212 seconds with exit status 0 (successful).
......
1 ---
2 name: Bug report
3 about: Create a report to help us improve
4
5 ---
6
7 **Describe the bug**
8 A clear and concise description of what the bug is.
9
10 **To Reproduce**
11 Steps to reproduce the behavior:
12 1. Go to '...'
13 2. Click on '....'
14 3. Scroll down to '....'
15 4. See error
16
17 **Expected behavior**
18 A clear and concise description of what you expected to happen.
19
20 **Screenshots**
21 1. Role Based Price For WooCommerce Settings
22 2. WC Price Editor View (For the product which has the issue)
23 If applicable, add screenshots to help explain your problem.
24
25 **Software Versions**
26 1. WordPress :
27 2. WooCommerce :
28 3. Role Based Price For WooCommerce :
29
30 **Desktop (please complete the following information):**
31 - OS: [e.g. iOS]
32 - Browser [e.g. chrome, safari]
33 - Version [e.g. 22]
34
35 **Smartphone (please complete the following information):**
36 - Device: [e.g. iPhone6]
37 - OS: [e.g. iOS8.1]
38 - Browser [e.g. stock browser, safari]
39 - Version [e.g. 22]
40
41 **Additional context**
42 Add any other context about the problem here.
1 ---
2 name: Feature request
3 about: Suggest an idea for this project
4
5 ---
6
7 **Is your feature request related to a problem? Please describe.**
8 A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9
10 **Describe the solution you'd like**
11 A clear and concise description of what you want to happen.
12
13 **Describe alternatives you've considered**
14 A clear and concise description of any alternative solutions or features you've considered.
15
16 **Additional context**
17 Add any other context or screenshots about the feature request here.
1 name: PHP CI/CD
2
3 env:
4 VS_WORKFLOW_TYPE: "php-cicd"
5
6 on:
7 push:
8 branches:
9 - master
10 - main
11 paths:
12 - '**.php'
13
14 jobs:
15 apigen_docs:
16 name: "ApiGen Docs"
17 runs-on: ubuntu-latest
18 steps:
19 - name: "📥 Fetching Repository Contents"
20 uses: actions/checkout@main
21
22 - name: "💾 Github Repository Metadata"
23 uses: varunsridharan/action-repository-meta@main
24 env:
25 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26
27 - name: "💫 VS Utility"
28 uses: varunsridharan/action-vs-utility@main
29
30 - name: " Repository - Before Hook"
31 run: |
32 echo " "
33 if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then
34 echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION"
35 sh $VS_BEFORE_HOOK_FILE_LOCATION
36 else
37 echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION"
38 fi
39 echo " "
40
41 - name: "📚 Generating Code Documentation"
42 uses: varunsridharan/action-apigen@2.1
43 env:
44 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
46 - name: " Repository - After Hook"
47 run: |
48 echo " "
49 if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then
50 echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION"
51 sh $VS_AFTER_HOOK_FILE_LOCATION
52 else
53 echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION"
54 fi
55 echo " "
...\ No newline at end of file ...\ No newline at end of file
1 name: Twitter Post On Release
2
3 env:
4 VS_WORKFLOW_TYPE: "twitter-post"
5
6 on:
7 release:
8 types:
9 - published
10
11 jobs:
12 twitter_post:
13 name: "🐦 Tweet"
14 runs-on: ubuntu-latest
15 steps:
16 - name: "📥 Fetching Repository Contents"
17 uses: actions/checkout@main
18
19 - name: "💾 Github Repository Metadata"
20 uses: varunsridharan/action-repository-meta@main
21 env:
22 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23
24 - name: "💫 VS Utility"
25 uses: varunsridharan/action-vs-utility@main
26 env:
27 SVA_ONL_TOKEN: ${{ secrets.SVA_ONL_TOKEN }}
28
29 - name: " Repository - Before Hook"
30 run: |
31 echo " "
32 if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then
33 echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION"
34 sh $VS_BEFORE_HOOK_FILE_LOCATION
35 else
36 echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION"
37 fi
38 echo " "
39
40 - name: "🚀 Publishing Tweet 🐦 "
41 uses: m1ner79/Github-Twittction@master
42 with:
43 twitter_status: ${{ env.TWITTER_STATUS }}
44 twitter_consumer_key: ${{ secrets.TWITTER_API_KEY }}
45 twitter_consumer_secret: ${{ secrets.TWITTER_API_SECRET_KEY }}
46 twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN }}
47 twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_SECRET_TOKEN }}
48
49 - name: " Repository - After Hook"
50 run: |
51 echo " "
52 if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then
53 echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION"
54 sh $VS_AFTER_HOOK_FILE_LOCATION
55 else
56 echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION"
57 fi
58 echo " "
...\ No newline at end of file ...\ No newline at end of file
1 name: "Release - WordPress.org"
2
3 env:
4 DIST_LOCATION: "./dist/"
5 VS_WORKFLOW_TYPE: "wordpress-org-release"
6
7 on:
8 release:
9 types:
10 - published
11
12 jobs:
13 publish-wordpress-org:
14 name: "🚀 WordPress Publisher"
15 runs-on: ubuntu-latest
16 steps:
17 - name: "📥 Fetching Repository Contents"
18 uses: actions/checkout@main
19
20 - name: "💾 Github Repository Metadata"
21 uses: varunsridharan/action-repository-meta@main
22 env:
23 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
25 - name: "💫 VS Utility"
26 uses: varunsridharan/action-vs-utility@main
27
28 - name: " Repository - Before Hook"
29 run: |
30 echo " "
31 if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then
32 echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION"
33 sh $VS_BEFORE_HOOK_FILE_LOCATION
34 else
35 echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION"
36 fi
37 echo " "
38
39 - name: "💽 Installing Composer"
40 uses: g-actions/composer-action@main
41 with:
42 command: install --no-dev
43
44 - name: "🚀 Publishing Release"
45 uses: varunsridharan/action-wp-org-deploy@main
46 with:
47 WORDPRESS_PASSWORD: ${{ secrets.WP_PASSWORD }}
48 WORDPRESS_USERNAME: ${{ secrets.WP_USERNAME }}
49 SLUG: ${{ env.GITHUB_REPOSITORY_NAME }}
50 IGNORE_FILE: ${{ env.WORDPRESS_DIST_IGNORE }}
51 ASSETS_IGNORE_FILE: ${{ env.WORDPRESS_ASSETS_DIST_IGNORE }}
52 DIST_LOCATION: ${{ env.DIST_LOCATION }}
53
54 - name: "📦 Upload ZIP To Release in Github"
55 uses: Roang-zero1/github-upload-release-artifacts-action@master
56 with:
57 args: ${{ env.DIST_LOCATION }}
58 env:
59 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60
61 - name: " Repository - After Hook"
62 run: |
63 echo " "
64 if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then
65 echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION"
66 sh $VS_AFTER_HOOK_FILE_LOCATION
67 else
68 echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION"
69 fi
70 echo " "
...\ No newline at end of file ...\ No newline at end of file
1
2 plugins/price-add-to-cart-visibility/Thumbs.db
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11 software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14 to take away your freedom to share and change the works. By contrast,
15 the GNU General Public License is intended to guarantee your freedom to
16 share and change all versions of a program--to make sure it remains free
17 software for all its users. We, the Free Software Foundation, use the
18 GNU General Public License for most of our software; it applies also to
19 any other work released this way by its authors. You can apply it to
20 your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23 price. Our General Public Licenses are designed to make sure that you
24 have the freedom to distribute copies of free software (and charge for
25 them if you wish), that you receive source code or can get it if you
26 want it, that you can change the software or use pieces of it in new
27 free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30 these rights or asking you to surrender the rights. Therefore, you have
31 certain responsibilities if you distribute copies of the software, or if
32 you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35 gratis or for a fee, you must pass on to the recipients the same
36 freedoms that you received. You must make sure that they, too, receive
37 or can get the source code. And you must show them these terms so they
38 know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41 (1) assert copyright on the software, and (2) offer you this License
42 giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45 that there is no warranty for this free software. For both users' and
46 authors' sake, the GPL requires that modified versions be marked as
47 changed, so that their problems will not be attributed erroneously to
48 authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51 modified versions of the software inside them, although the manufacturer
52 can do so. This is fundamentally incompatible with the aim of
53 protecting users' freedom to change the software. The systematic
54 pattern of such abuse occurs in the area of products for individuals to
55 use, which is precisely where it is most unacceptable. Therefore, we
56 have designed this version of the GPL to prohibit the practice for those
57 products. If such problems arise substantially in other domains, we
58 stand ready to extend this provision to those domains in future versions
59 of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62 States should not allow patents to restrict development and use of
63 software on general-purpose computers, but in those that do, we wish to
64 avoid the special danger that patents applied to a free program could
65 make it effectively proprietary. To prevent this, the GPL assures that
66 patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69 modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78 works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81 License. Each licensee is addressed as "you". "Licensees" and
82 "recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85 in a fashion requiring copyright permission, other than the making of an
86 exact copy. The resulting work is called a "modified version" of the
87 earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90 on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93 permission, would make you directly or secondarily liable for
94 infringement under applicable copyright law, except executing it on a
95 computer or modifying a private copy. Propagation includes copying,
96 distribution (with or without modification), making available to the
97 public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100 parties to make or receive copies. Mere interaction with a user through
101 a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104 to the extent that it includes a convenient and prominently visible
105 feature that (1) displays an appropriate copyright notice, and (2)
106 tells the user that there is no warranty for the work (except to the
107 extent that warranties are provided), that licensees may convey the
108 work under this License, and how to view a copy of this License. If
109 the interface presents a list of user commands or options, such as a
110 menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115 for making modifications to it. "Object code" means any non-source
116 form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119 standard defined by a recognized standards body, or, in the case of
120 interfaces specified for a particular programming language, one that
121 is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124 than the work as a whole, that (a) is included in the normal form of
125 packaging a Major Component, but which is not part of that Major
126 Component, and (b) serves only to enable use of the work with that
127 Major Component, or to implement a Standard Interface for which an
128 implementation is available to the public in source code form. A
129 "Major Component", in this context, means a major essential component
130 (kernel, window system, and so on) of the specific operating system
131 (if any) on which the executable work runs, or a compiler used to
132 produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135 the source code needed to generate, install, and (for an executable
136 work) run the object code and to modify the work, including scripts to
137 control those activities. However, it does not include the work's
138 System Libraries, or general-purpose tools or generally available free
139 programs which are used unmodified in performing those activities but
140 which are not part of the work. For example, Corresponding Source
141 includes interface definition files associated with source files for
142 the work, and the source code for shared libraries and dynamically
143 linked subprograms that the work is specifically designed to require,
144 such as by intimate data communication or control flow between those
145 subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148 can regenerate automatically from other parts of the Corresponding
149 Source.
150
151 The Corresponding Source for a work in source code form is that
152 same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157 copyright on the Program, and are irrevocable provided the stated
158 conditions are met. This License explicitly affirms your unlimited
159 permission to run the unmodified Program. The output from running a
160 covered work is covered by this License only if the output, given its
161 content, constitutes a covered work. This License acknowledges your
162 rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165 convey, without conditions so long as your license otherwise remains
166 in force. You may convey covered works to others for the sole purpose
167 of having them make modifications exclusively for you, or provide you
168 with facilities for running those works, provided that you comply with
169 the terms of this License in conveying all material for which you do
170 not control copyright. Those thus making or running the covered works
171 for you must do so exclusively on your behalf, under your direction
172 and control, on terms that prohibit them from making any copies of
173 your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176 the conditions stated below. Sublicensing is not allowed; section 10
177 makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182 measure under any applicable law fulfilling obligations under article
183 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 similar laws prohibiting or restricting circumvention of such
185 measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188 circumvention of technological measures to the extent such circumvention
189 is effected by exercising rights under this License with respect to
190 the covered work, and you disclaim any intention to limit operation or
191 modification of the work as a means of enforcing, against the work's
192 users, your or third parties' legal rights to forbid circumvention of
193 technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198 receive it, in any medium, provided that you conspicuously and
199 appropriately publish on each copy an appropriate copyright notice;
200 keep intact all notices stating that this License and any
201 non-permissive terms added in accord with section 7 apply to the code;
202 keep intact all notices of the absence of any warranty; and give all
203 recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206 and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211 produce it from the Program, in the form of source code under the
212 terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236 works, which are not by their nature extensions of the covered work,
237 and which are not combined with it such as to form a larger program,
238 in or on a volume of a storage or distribution medium, is called an
239 "aggregate" if the compilation and its resulting copyright are not
240 used to limit the access or legal rights of the compilation's users
241 beyond what the individual works permit. Inclusion of a covered work
242 in an aggregate does not cause this License to apply to the other
243 parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248 of sections 4 and 5, provided that you also convey the
249 machine-readable Corresponding Source under the terms of this License,
250 in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294 from the Corresponding Source as a System Library, need not be
295 included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298 tangible personal property which is normally used for personal, family,
299 or household purposes, or (2) anything designed or sold for incorporation
300 into a dwelling. In determining whether a product is a consumer product,
301 doubtful cases shall be resolved in favor of coverage. For a particular
302 product received by a particular user, "normally used" refers to a
303 typical or common use of that class of product, regardless of the status
304 of the particular user or of the way in which the particular user
305 actually uses, or expects or is expected to use, the product. A product
306 is a consumer product regardless of whether the product has substantial
307 commercial, industrial or non-consumer uses, unless such uses represent
308 the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311 procedures, authorization keys, or other information required to install
312 and execute modified versions of a covered work in that User Product from
313 a modified version of its Corresponding Source. The information must
314 suffice to ensure that the continued functioning of the modified object
315 code is in no case prevented or interfered with solely because
316 modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319 specifically for use in, a User Product, and the conveying occurs as
320 part of a transaction in which the right of possession and use of the
321 User Product is transferred to the recipient in perpetuity or for a
322 fixed term (regardless of how the transaction is characterized), the
323 Corresponding Source conveyed under this section must be accompanied
324 by the Installation Information. But this requirement does not apply
325 if neither you nor any third party retains the ability to install
326 modified object code on the User Product (for example, the work has
327 been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330 requirement to continue to provide support service, warranty, or updates
331 for a work that has been modified or installed by the recipient, or for
332 the User Product in which it has been modified or installed. Access to a
333 network may be denied when the modification itself materially and
334 adversely affects the operation of the network or violates the rules and
335 protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338 in accord with this section must be in a format that is publicly
339 documented (and with an implementation available to the public in
340 source code form), and must require no special password or key for
341 unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346 License by making exceptions from one or more of its conditions.
347 Additional permissions that are applicable to the entire Program shall
348 be treated as though they were included in this License, to the extent
349 that they are valid under applicable law. If additional permissions
350 apply only to part of the Program, that part may be used separately
351 under those permissions, but the entire Program remains governed by
352 this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355 remove any additional permissions from that copy, or from any part of
356 it. (Additional permissions may be written to require their own
357 removal in certain cases when you modify the work.) You may place
358 additional permissions on material, added by you to a covered work,
359 for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362 add to a covered work, you may (if authorized by the copyright holders of
363 that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389 restrictions" within the meaning of section 10. If the Program as you
390 received it, or any part of it, contains a notice stating that it is
391 governed by this License along with a term that is a further
392 restriction, you may remove that term. If a license document contains
393 a further restriction but permits relicensing or conveying under this
394 License, you may add to a covered work material governed by the terms
395 of that license document, provided that the further restriction does
396 not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399 must place, in the relevant source files, a statement of the
400 additional terms that apply to those files, or a notice indicating
401 where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404 form of a separately written license, or stated as exceptions;
405 the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410 provided under this License. Any attempt otherwise to propagate or
411 modify it is void, and will automatically terminate your rights under
412 this License (including any patent licenses granted under the third
413 paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416 license from a particular copyright holder is reinstated (a)
417 provisionally, unless and until the copyright holder explicitly and
418 finally terminates your license, and (b) permanently, if the copyright
419 holder fails to notify you of the violation by some reasonable means
420 prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423 reinstated permanently if the copyright holder notifies you of the
424 violation by some reasonable means, this is the first time you have
425 received notice of violation of this License (for any work) from that
426 copyright holder, and you cure the violation prior to 30 days after
427 your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430 licenses of parties who have received copies or rights from you under
431 this License. If your rights have been terminated and not permanently
432 reinstated, you do not qualify to receive new licenses for the same
433 material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438 run a copy of the Program. Ancillary propagation of a covered work
439 occurring solely as a consequence of using peer-to-peer transmission
440 to receive a copy likewise does not require acceptance. However,
441 nothing other than this License grants you permission to propagate or
442 modify any covered work. These actions infringe copyright if you do
443 not accept this License. Therefore, by modifying or propagating a
444 covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449 receives a license from the original licensors, to run, modify and
450 propagate that work, subject to this License. You are not responsible
451 for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454 organization, or substantially all assets of one, or subdividing an
455 organization, or merging organizations. If propagation of a covered
456 work results from an entity transaction, each party to that
457 transaction who receives a copy of the work also receives whatever
458 licenses to the work the party's predecessor in interest had or could
459 give under the previous paragraph, plus a right to possession of the
460 Corresponding Source of the work from the predecessor in interest, if
461 the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464 rights granted or affirmed under this License. For example, you may
465 not impose a license fee, royalty, or other charge for exercise of
466 rights granted under this License, and you may not initiate litigation
467 (including a cross-claim or counterclaim in a lawsuit) alleging that
468 any patent claim is infringed by making, using, selling, offering for
469 sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474 License of the Program or a work on which the Program is based. The
475 work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478 owned or controlled by the contributor, whether already acquired or
479 hereafter acquired, that would be infringed by some manner, permitted
480 by this License, of making, using, or selling its contributor version,
481 but do not include claims that would be infringed only as a
482 consequence of further modification of the contributor version. For
483 purposes of this definition, "control" includes the right to grant
484 patent sublicenses in a manner consistent with the requirements of
485 this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488 patent license under the contributor's essential patent claims, to
489 make, use, sell, offer for sale, import and otherwise run, modify and
490 propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493 agreement or commitment, however denominated, not to enforce a patent
494 (such as an express permission to practice a patent or covenant not to
495 sue for patent infringement). To "grant" such a patent license to a
496 party means to make such an agreement or commitment not to enforce a
497 patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500 and the Corresponding Source of the work is not available for anyone
501 to copy, free of charge and under the terms of this License, through a
502 publicly available network server or other readily accessible means,
503 then you must either (1) cause the Corresponding Source to be so
504 available, or (2) arrange to deprive yourself of the benefit of the
505 patent license for this particular work, or (3) arrange, in a manner
506 consistent with the requirements of this License, to extend the patent
507 license to downstream recipients. "Knowingly relying" means you have
508 actual knowledge that, but for the patent license, your conveying the
509 covered work in a country, or your recipient's use of the covered work
510 in a country, would infringe one or more identifiable patents in that
511 country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514 arrangement, you convey, or propagate by procuring conveyance of, a
515 covered work, and grant a patent license to some of the parties
516 receiving the covered work authorizing them to use, propagate, modify
517 or convey a specific copy of the covered work, then the patent license
518 you grant is automatically extended to all recipients of the covered
519 work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522 the scope of its coverage, prohibits the exercise of, or is
523 conditioned on the non-exercise of one or more of the rights that are
524 specifically granted under this License. You may not convey a covered
525 work if you are a party to an arrangement with a third party that is
526 in the business of distributing software, under which you make payment
527 to the third party based on the extent of your activity of conveying
528 the work, and under which the third party grants, to any of the
529 parties who would receive the covered work from you, a discriminatory
530 patent license (a) in connection with copies of the covered work
531 conveyed by you (or copies made from those copies), or (b) primarily
532 for and in connection with specific products or compilations that
533 contain the covered work, unless you entered into that arrangement,
534 or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537 any implied license or other defenses to infringement that may
538 otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543 otherwise) that contradict the conditions of this License, they do not
544 excuse you from the conditions of this License. If you cannot convey a
545 covered work so as to satisfy simultaneously your obligations under this
546 License and any other pertinent obligations, then as a consequence you may
547 not convey it at all. For example, if you agree to terms that obligate you
548 to collect a royalty for further conveying from those to whom you convey
549 the Program, the only way you could satisfy both those terms and this
550 License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555 permission to link or combine any covered work with a work licensed
556 under version 3 of the GNU Affero General Public License into a single
557 combined work, and to convey the resulting work. The terms of this
558 License will continue to apply to the part which is the covered work,
559 but the special requirements of the GNU Affero General Public License,
560 section 13, concerning interaction through a network will apply to the
561 combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566 the GNU General Public License from time to time. Such new versions will
567 be similar in spirit to the present version, but may differ in detail to
568 address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571 Program specifies that a certain numbered version of the GNU General
572 Public License "or any later version" applies to it, you have the
573 option of following the terms and conditions either of that numbered
574 version or of any later version published by the Free Software
575 Foundation. If the Program does not specify a version number of the
576 GNU General Public License, you may choose any version ever published
577 by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580 versions of the GNU General Public License can be used, that proxy's
581 public statement of acceptance of a version permanently authorizes you
582 to choose that version for the Program.
583
584 Later license versions may give you additional or different
585 permissions. However, no additional obligations are imposed on any
586 author or copyright holder as a result of your choosing to follow a
587 later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615 above cannot be given local legal effect according to their terms,
616 reviewing courts shall apply local law that most closely approximates
617 an absolute waiver of all civil liability in connection with the
618 Program, unless a warranty or assumption of liability accompanies a
619 copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626 possible use to the public, the best way to achieve this is to make it
627 free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630 to attach them to the start of each source file to most effectively
631 state the exclusion of warranty; and each file should have at least
632 the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <http://www.gnu.org/licenses/>.
649
650 Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653 notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660 The hypothetical commands `show w' and `show c' should show the appropriate
661 parts of the General Public License. Of course, your program's commands
662 might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665 if any, to sign a "copyright disclaimer" for the program, if necessary.
666 For more information on this, and how to apply and follow the GNU GPL, see
667 <http://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670 into proprietary programs. If your program is a subroutine library, you
671 may consider it more useful to permit linking proprietary applications with
672 the library. If this is what you want to do, use the GNU Lesser General
673 Public License instead of this License. But first, please read
674 <http://www.gnu.org/philosophy/why-not-lgpl.html>.
1 <?php
2 /**
3 * Plugin Main File
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/core
8 * @since 3.0
9 */
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price {
15 protected static $_instance = null;
16 protected static $functions = null;
17 protected static $admin = null; # Required Plugin Class Instance
18 protected static $settings = null; # Required Plugin Class Instance
19 protected static $frontend = null; # Required Plugin Class Instance
20 protected static $shortcode_handler = null; # Required Plugin Class Instance
21 public $version = '3.3.5'; # Required Plugin Class INstance
22 public $plugin_vars = array(); # Required Plugin Class INstance
23
24 /**
25 * Class Constructor
26 */
27 public function __construct() {
28 $this->define_constant();
29 $this->load_required_files();
30 $this->init_hooks();
31 do_action( 'wc_rbp_loaded' );
32 }
33
34 /**
35 * Define Required Constant
36 */
37 private function define_constant() {
38 $this->define( 'WC_RBP_NAME', 'Role Based Price For WooCommerce' ); # Plugin Name
39 $this->define( 'WC_RBP_SLUG', 'woocommerce-role-based-price' ); # Plugin Slug
40 $this->define( 'WC_RBP_TXT', 'woocommerce-role-based-price' ); #plugin lang Domain
41 $this->define( 'WC_RBP_DB', 'wc_rbp_' );
42 $this->define( 'WC_RBP_V', $this->version ); # Plugin Version
43
44 $this->define( 'WC_RBP_LANGUAGE_PATH', WC_RBP_PATH . 'languages' ); # Plugin Language Folder
45 $this->define( 'WC_RBP_ADMIN', WC_RBP_INC . 'admin/' ); # Plugin Admin Folder
46 $this->define( 'WC_RBP_SETTINGS', WC_RBP_ADMIN . 'settings/' ); # Plugin Settings Folder
47 $this->define( 'WC_RBP_PLUGIN', WC_RBP_PATH . 'plugins/' );
48
49 $this->define( 'WC_RBP_URL', plugins_url( '', __FILE__ ) . '/' ); # Plugin URL
50 $this->define( 'WC_RBP_PLUGIN_URL', WC_RBP_URL . 'plugins/' ); # Plugin URL
51 $this->define( 'WC_RBP_CSS', WC_RBP_URL . 'includes/css/' ); # Plugin CSS URL
52 $this->define( 'WC_RBP_IMG', WC_RBP_URL . 'includes/img/' ); # Plugin IMG URL
53 $this->define( 'WC_RBP_JS', WC_RBP_URL . 'includes/js/' ); # Plugin JS URL
54 }
55
56 /**
57 * Define constant if not already set
58 *
59 * @param string $name
60 * @param string|bool $value
61 */
62 protected function define( $key, $value ) {
63 if ( ! defined( $key ) ) {
64 define( $key, $value );
65 }
66 }
67
68 /**
69 * Loads Required Plugins For Plugin
70 */
71 private function load_required_files() {
72 $this->load_files( WC_RBP_INC . 'abstract-*.php' );
73 $this->load_files( WC_RBP_INC . 'helpers/class-admin-notice.php' );
74 $this->load_files( WC_RBP_INC . 'class-*.php' );
75 $this->load_files( WC_RBP_ADMIN . 'settings_framework/class-wp-plugin-options.php' );
76 $this->load_files( WC_RBP_ADMIN . 'settings_framework/class-wp-*.php' );
77
78 if ( wc_rbp_is_request( 'admin' ) ) {
79 $this->load_files( WC_RBP_ADMIN . 'class-*.php' );
80 }
81
82 do_action( 'wc_rbp_before_addons_load' );
83 $this->load_addons();
84
85 }
86
87 /**
88 * Loads Files Based On Give Path & regex
89 */
90 protected function load_files( $path, $type = 'require' ) {
91 foreach ( glob( $path ) as $files ) {
92 if ( $type == 'require' ) {
93 require_once( $files );
94 } elseif ( $type == 'include' ) {
95 include_once( $files );
96 }
97 }
98 }
99
100 public function load_addons() {
101 $addons = wc_rbp_get_active_addons();
102 if ( ! empty( $addons ) ) {
103 foreach ( $addons as $addon ) {
104 if ( apply_filters( 'wc_rbp_load_addon', true, $addon ) ) {
105 do_action( 'wc_rbp_before_' . $addon . '_addon_load' );
106 $this->load_addon( $addon );
107 do_action( 'wc_rbp_after_' . $addon . '_addon_load' );
108 }
109 }
110 }
111 }
112
113 public function load_addon( $file ) {
114 $other_file = apply_filters( 'wc_rbp_addon_file_location', $file );
115
116 if ( file_exists( WC_RBP_PLUGIN . $file ) ) {
117 $this->load_files( WC_RBP_PLUGIN . $file );
118 } elseif ( file_exists( $other_file ) ) {
119 $this->load_files( $other_file );
120 } else {
121 if ( has_action( 'wc_rbp_addon_' . $file . '_load' ) ) {
122 do_action( 'wc_rbp_addon_' . $file . '_load' );
123 } else {
124 wc_rbp_deactivate_addon( $file );
125 }
126 }
127
128 }
129
130 public function init_hooks() {
131 add_action( 'plugins_loaded', array( $this, 'after_plugins_loaded' ) );
132 add_filter( 'load_textdomain_mofile', array( $this, 'load_plugin_mo_files' ), 10, 2 );
133 add_action( 'init', array( $this, 'init' ), 0 );
134 }
135
136 /**
137 * Creates or returns an instance of this class.
138 */
139 public static function get_instance() {
140 if ( null == self::$_instance ) {
141 self::$_instance = new self;
142 }
143 return self::$_instance;
144 }
145
146 # Returns Plugin's Functions Instance
147
148 /**
149 * Throw error on object clone.
150 *
151 * Cloning instances of the class is forbidden.
152 *
153 * @since 1.0
154 * @return void
155 */
156 public function __clone() {
157 _doing_it_wrong( __FUNCTION__, __( 'Cloning instances of the class is forbidden.', WC_RBP_TXT ), WC_RBP_V );
158 }
159
160 # Returns Plugin's Functions Instance
161
162 /**
163 * Disable unserializing of the class
164 *
165 * Unserializing instances of the class is forbidden.
166 *
167 * @since 1.0
168 * @return void
169 */
170 public function __wakeup() {
171 _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of the class is forbidden.', WC_RBP_TXT ), WC_RBP_V );
172 }
173
174 # Returns Plugin's Settings Instance
175
176 /**
177 * Inits loaded Class
178 */
179 public function init() {
180 do_action( 'wc_rbp_before_init' );
181
182 self::$functions = new WooCommerce_Role_Based_Price_Functions;
183 self::$settings = new WooCommerce_Role_Based_Price_Settings_Framework;
184 self::$shortcode_handler = new WooCommerce_Role_Based_Price_Shortcode_Handler;
185
186 if ( wc_rbp_is_request( 'admin' ) ) {
187 self::$admin = new WooCommerce_Role_Based_Price_Admin;
188 } else {
189 self::$frontend = new WooCommerce_Role_Based_Price_Product_Pricing;
190 }
191
192 do_action( 'wc_rbp_init' );
193 }
194
195 # Returns Plugin's Admin Instance
196
197 public function func() {
198 return self::$functions;
199 }
200
201 public function frontend() {
202 return self::$frontend;
203 }
204
205 public function settings() {
206 return self::$settings;
207 }
208
209 public function admin() {
210 return self::$admin;
211 }
212
213 /**
214 * Set Plugin Text Domain
215 */
216 public function after_plugins_loaded() {
217 load_plugin_textdomain( WC_RBP_TXT, false, WC_RBP_LANGUAGE_PATH );
218 }
219
220 /**
221 * load translated mo file based on wp settings
222 */
223 public function load_plugin_mo_files( $mofile, $domain ) {
224 if ( WC_RBP_TXT === $domain ) {
225 return WC_RBP_LANGUAGE_PATH . '/' . get_locale() . '.mo';
226 }
227 return $mofile;
228 }
229
230 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 *
4 * Addons Handler
5 *
6 * @link https://codecanyon.net/item/advanced-product-reviews-for-woocommerce/15385857
7 * @package APRWC
8 * @subpackage APRWC/FrontEnd
9 * @since 2.0
10 */
11 if( ! defined('WPINC') ) {
12 die;
13 }
14
15 class WooCommerce_Role_Based_Price_Addon_Handler {
16
17 public function __construct() {
18 add_filter('wc_rbp_addon_sections', array( $this, 'register_section' ));
19 add_filter('wc_rbp_addon_fields', array( $this, 'register_fields' ));
20
21 add_action('wp_enqueue_scripts', array( $this, 'frontend_style' ));
22 add_action('wp_enqueue_scripts', array( $this, 'frontend_script' ));
23
24 if( is_admin() ) {
25 add_action('wc_rbp_admin_styles', array( $this, 'admin_style' ));
26 add_action('wc_rbp_admin_scripts', array( $this, 'admin_script' ));
27 }
28
29 add_action('wc_rbp_loaded', array( $this, 'init_class' ));
30 }
31
32 public function register_section($settings_section) {
33 return $settings_section;
34 }
35
36 public function register_fields($settings_fields) {
37 return $settings_fields;
38 }
39
40 public function init_class() {
41 }
42
43 public function admin_style($screen = '') {
44 }
45
46 public function admin_script($screen = '') {
47 }
48
49 public function frontend_style() {
50 }
51
52 public function frontend_script() {
53 }
54
55 public function addon_path($file = __DIR__) {
56 return plugin_dir_path($file);
57 }
58
59 public function addon_url($file = __FILE__) {
60 return plugin_dir_url($file);
61 }
62 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Plugin's Admin code
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Admin {
15
16 /**
17 * Initialize the class and set its properties.
18 *
19 * @since 0.1
20 */
21 public function __construct() {
22 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ), 99 );
23 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
24 add_action( 'admin_init', array( $this, 'admin_init' ) );
25 add_filter( 'woocommerce_screen_ids', array( $this, 'set_wc_screen_ids' ), 99 );
26 add_filter( 'plugin_row_meta', array( $this, 'plugin_row_links' ), 10, 2 );
27 add_filter( 'plugin_action_links_' . WC_RBP_FILE, array( $this, 'plugin_action_links' ), 10, 10 );
28 //add_action( 'admin_menu',array($this,'add_welcome_menu'));
29 }
30
31
32 public function set_wc_screen_ids( $screens ) {
33 $screen = $screens;
34 $screen[] = 'woocommerce_page_woocommerce-role-based-price-settings';
35 $screen[] = 'product_page_rbp_global_addons';
36 return $screen;
37 }
38
39 /**
40 * Inits Admin Sttings
41 */
42 public function admin_init() {
43 //$this->handle_welcome_page();
44
45
46 new WooCommerce_Role_Based_Price_Admin_Ajax_Handler;
47 new WooCommerce_Role_Based_Price_Addons;
48 }
49
50 public function handle_welcome_page() {
51 if ( ! get_transient( '_welcome_redirect_wcrbp' ) ) {
52 return;
53 }
54
55 delete_transient( '_welcome_redirect_wcrbp' );
56
57 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
58 return;
59 }
60 wp_safe_redirect( add_query_arg( array( 'page' => 'wcrbp_welcome_page' ), admin_url( 'plugins.php' ) ) );
61 }
62
63 public function add_welcome_menu() {
64 if ( ! get_transient( '_welcome_redirect_wcrbp' ) ) {
65 //return;
66 }
67
68 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
69 return;
70 }
71
72 add_submenu_page( 'plugins.php', __( 'Role Based Price For WooCommerce Welcome Page', 'WPW' ), __( 'Role Based Price For WooCommerce Welcome Page', 'WPW' ), 'read', 'wcrbp_welcome_page', array(
73 $this,
74 'wcrbp_welcome_page_content',
75 ) );
76
77 }
78
79 public function wcrbp_welcome_page_content() {
80 include( WC_RBP_ADMIN . 'views/plugin-welcome-page.php' );
81 }
82
83 /**
84 * Register the stylesheets for the admin area.
85 */
86 public function enqueue_styles() {
87 $current_screen = wc_rbp_current_screen();
88 $addon_url = admin_url( 'admin-ajax.php?action=wc_rbp_addon_custom_css' );
89
90 wp_register_style( WC_RBP_SLUG . '_backend_style', WC_RBP_CSS . 'backend.css', array(), WC_RBP_V, 'all' );
91 wp_register_style( WC_RBP_SLUG . '_addons_style', $addon_url, array(), WC_RBP_V, 'all' );
92 wp_register_style( WC_RBP_SLUG . '_settings_selectize_style', WC_RBP_CSS . 'selectize.js.css', array(), WC_RBP_V, 'all' );
93 wp_register_style( WC_RBP_SLUG . '_tabs_style', WC_RBP_CSS . 'tabs.css', array(), WC_RBP_V, 'all' );
94
95 wp_enqueue_style( WC_RBP_SLUG . '_backend_style' );
96 wp_enqueue_style( WC_RBP_SLUG . '_addons_style' );
97
98
99 if ( 'woocommerce_page_woocommerce-role-based-price-settings' == $current_screen ) {
100 wp_enqueue_style( WC_RBP_SLUG . '_settings_selectize_style' );
101 add_thickbox();
102 }
103
104 if ( 'product' == $current_screen ) {
105 wp_enqueue_style( WC_RBP_SLUG . '_tabs_style' );
106 wp_enqueue_style( WC_RBP_SLUG . '_settings_selectize_style' );
107 }
108
109 do_action( 'wc_rbp_admin_styles', $current_screen );
110 }
111
112
113 /**
114 * Register the JavaScript for the admin area.
115 */
116 public function enqueue_scripts() {
117 $current_screen = wc_rbp_current_screen();
118
119 $addon_url = admin_url( 'admin-ajax.php?action=wc_rbp_addon_custom_js' );
120
121 wp_register_script( WC_RBP_SLUG . '_backend_script', WC_RBP_JS . 'backend.js', array( 'jquery' ), WC_RBP_V, false );
122 wp_register_script( WC_RBP_SLUG . '_addons_script', $addon_url, array( 'jquery' ), WC_RBP_V, false );
123 wp_register_script( WC_RBP_SLUG . '_settings_selectize.js', WC_RBP_JS . 'selectize.js', array( 'jquery' ), WC_RBP_V, false );
124 wp_register_script( WC_RBP_SLUG . '_settings_checkbox.js', WC_RBP_JS . 'checkbox.js', array( 'jquery' ), WC_RBP_V, false );
125 wp_register_script( WC_RBP_SLUG . '_settings_js', WC_RBP_JS . 'settings-page.js', array(
126 'jquery',
127 WC_RBP_SLUG . '_settings_selectize.js',
128 ), WC_RBP_V, false );
129 wp_register_script( WC_RBP_SLUG . '_settings_checkbox.js', WC_RBP_JS . 'checkbox.js', array( 'jquery' ), WC_RBP_V, false );
130 wp_register_script( WC_RBP_SLUG . '_jquery-tabs-script', WC_RBP_JS . 'tabs.js', array( 'jquery' ), WC_RBP_V, false );
131
132 wp_enqueue_script( WC_RBP_SLUG . '_backend_script', WC_RBP_JS . 'backend.js', array( 'jquery' ), WC_RBP_V, false );
133
134
135 if ( in_array( $current_screen, wc_rbp_get_screen_ids() ) ) {
136 }
137
138 if ( 'woocommerce_page_woocommerce-role-based-price-settings' == $current_screen ) {
139 wp_enqueue_script( WC_RBP_SLUG . '_settings_selectize.js' );
140 wp_enqueue_script( WC_RBP_SLUG . '_settings_checkbox.js' );
141 wp_enqueue_script( WC_RBP_SLUG . '_settings_js' );
142
143 $msg = '<h3>' . __( 'Thanks For Your Continued Support For %1$s' ) . '</h3>';
144 $msg .= __( 'We Are Already In A Process For Created Version 4.0 For This Plugin' );
145 $msg .= '<br/><br/><a href="https://forms.gle/waxC4Mm9SZFWuq3A8" class="button button-secondary">' . __( 'Join Newsletter / Request Beta Access' ) . '</a>';
146 $msg = sprintf( $msg, WC_RBP_NAME );
147 wc_rbp_admin_update( $msg, 1, array(), array() );
148 }
149
150 if ( 'product' == $current_screen ) {
151 wp_enqueue_script( WC_RBP_SLUG . '_settings_checkbox.js' );
152 wp_enqueue_script( WC_RBP_SLUG . '_jquery-tabs-script' );
153 wp_enqueue_script( WC_RBP_SLUG . '_jquery-product-script' );
154 wp_enqueue_script( WC_RBP_SLUG . '_settings_selectize.js' );
155 }
156
157 do_action( 'wc_rbp_admin_scripts', $current_screen );
158
159 wp_enqueue_script( WC_RBP_SLUG . '_addons_script', $addon_url, array( 'jquery' ), WC_RBP_V, false );
160 }
161
162
163 /**
164 * Adds Some Plugin Options
165 *
166 * @param array $plugin_meta
167 * @param string $plugin_file
168 *
169 * @return array
170 * @since 0.11
171 */
172 public function plugin_action_links( $action, $file, $plugin_meta, $status ) {
173 $url = admin_url( 'admin.php?page=woocommerce-role-based-price-settings' );
174 $addonurl = admin_url( 'admin.php?page=woocommerce-role-based-price-settings&tab=wcrbpaddons' );
175
176 $actions[] = sprintf( '<a href="%s">%s</a>', $url, __( 'Settings', WC_RBP_TXT ) );
177 $actions[] = sprintf( '<a href="%s">%s</a>', $addonurl, __( 'Add-ons', WC_RBP_TXT ) );
178
179 $action = array_merge( $actions, $action );
180 return $action;
181 }
182
183 /**
184 * Adds Some Plugin Options
185 *
186 * @param array $plugin_meta
187 * @param string $plugin_file
188 *
189 * @return array
190 * @since 0.11
191 */
192 public function plugin_row_links( $plugin_meta, $plugin_file ) {
193 if ( WC_RBP_FILE == $plugin_file ) {
194 $plugin_meta[] = sprintf( '<a href="%s">%s</a>', '#', __( 'Docs', WC_RBP_TXT ) );
195 $plugin_meta[] = sprintf( '<a href="%s">%s</a>', 'https://github.com/varunsridharan/woocommerce-role-based-price', __( 'View On Github', WC_RBP_TXT ) );
196 $plugin_meta[] = sprintf( '<a href="%s">%s</a>', 'https://github.com/varunsridharan/woocommerce-role-based-price/issues', __( 'Report Issue', WC_RBP_TXT ) );
197 $plugin_meta[] = sprintf( '&hearts; <a href="%s">%s</a>', 'https://www.paypal.me/varunsridharan23', __( 'Donate', WC_RBP_TXT ) );
198 $plugin_meta[] = sprintf( '<a href="%s">%s</a>', 'http://varunsridharan.in/plugin-support/', __( 'Contact Author', WC_RBP_TXT ) );
199 }
200 return $plugin_meta;
201 }
202 }
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Admin_Ajax_Handler {
15
16 public function __construct() {
17 add_action('wp_ajax_wc_rbp_clear_variation_cache', array( $this, 'clear_variation_cache' ));
18 add_action('wp_ajax_wc_rbp_save_product_prices', array( $this, 'save_product_rbp_price' ));
19 add_action('wp_ajax_nopriv_wc_rbp_addon_custom_css', array( $this, 'render_addon_css' ));
20 add_action('wp_ajax_wc_rbp_addon_custom_css', array( $this, 'render_addon_css' ));
21 add_action('wp_ajax_nopriv_wc_rbp_addon_custom_js', array( $this, 'render_addon_js' ));
22 add_action('wp_ajax_wc_rbp_addon_custom_js', array( $this, 'render_addon_js' ));
23
24 add_action('wp_ajax_wc_rbp_metabox_refersh', array( $this, 'refresh_metabox' ));
25 }
26
27 public function clear_variation_cache() {
28 if( ! isset($_REQUEST['post_id']) ) {
29 wp_send_json_error(__('Invalid Product ID', WC_RBP_TXT));
30 }
31 $id = sanitize_text_field($_REQUEST['post_id']);
32
33 $parent = wp_get_post_parent_id($id);
34 if( $parent !== FALSE ) {
35 $allowed_roles = array_keys(wc_rbp_get_user_roles_selectbox());
36 foreach( $allowed_roles as $role ) {
37 wc_rbp_delete_variation_data($id, $role);
38 }
39 }
40
41 wp_send_json_success(array( __("Success") ));
42 }
43
44 public function refresh_metabox() {
45 if( ! isset($_REQUEST['pid']) ) {
46 wp_send_json_error(__('Invalid Product ID', WC_RBP_TXT));
47 }
48
49 if( ! isset($_REQUEST['parentID']) ) {
50 wp_send_json_error(__('Invalid Product ID', WC_RBP_TXT));
51 }
52
53 $id = sanitize_text_field($_REQUEST['pid']);
54 $parentid = sanitize_text_field($_REQUEST['parentID']);
55 $metabox = new WooCommerce_Role_Based_Price_Product_Metabox;
56 ob_start();
57 //$metabox->generate_variation_selectbox($parentid,$id);
58 $metabox->render_price_editor_metabox($id);
59 $content = ob_get_contents();
60 ob_end_clean();
61 wp_send_json_success($content);
62 wp_die();
63 }
64
65 public function render_addon_css() {
66 header('Content-Type: text/css');
67 do_action('wc_rbp_addon_styles');
68 wp_die();
69 }
70
71 public function render_addon_js() {
72 header('Content-Type: text/javascript');
73 do_action('wc_rbp_addon_scripts');
74 wp_die();
75 }
76
77 public function save_product_rbp_price() {
78 $is_verifyed_nounce = wp_verify_nonce($_POST['wc_rbp_nounce'], 'wc_rbp_save_product_prices');
79 $error = array();
80 $type = isset($_POST['type']) ? $_POST['type'] : 'default';
81 $success = array( 'hidden_fields' => wc_rbp_get_editor_fields($type) );
82 $posted_values = $_POST;
83
84 if( $is_verifyed_nounce ) {
85 do_action_ref_array('wc_rbp_product_save_' . $type, array( &$posted_values, &$success, &$error ));
86 } else {
87 $error['html'] = '<h3>' . __("Unable To Process Your Request Please Try Again later", WC_RBP_TXT) . '</h3>';
88 }
89
90 if( empty($error) ) {
91 wp_send_json_success($success);
92 } else {
93 $error['hidden_fields'] = wc_rbp_get_editor_fields($type);
94 wp_send_json_error($error);
95 }
96 wp_die();
97 }
98 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Admin_Sample_Class {
15
16 public function __construct() {
17
18 }
19 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 class WooCommerce_Role_Based_Price_Product_Metabox {
4
5 public function __construct() {
6 add_action('add_meta_boxes_product', array( $this, 'add_metabox' ));
7 }
8
9 public function add_metabox($post) {
10 add_meta_box('wc-rbp-product-editor', __('Role Based Price For WooCommerce Editor', WC_RBP_TXT), array(
11 $this,
12 'render_price_editor_metabox',
13 ), 'product', 'advanced', 'high');
14 }
15
16 public function render_price_editor_metabox($post) {
17 if( is_object($post) ) {
18 $id = $post->ID;
19 } else {
20 $id = $post;
21 }
22
23 $prod = NULL;
24 $prodType = $this->get_post_type($id);
25
26 $url = admin_url('admin-ajax.php?action=wc_rbp_save_product_prices');
27 $render_info = '<div class="wc-rbp-metabox-container" method="POST" action="' . $url . '" > ';
28 $render_info .= wc_rbp_get_ajax_overlay();
29
30 $this->allowed_roles = wc_rbp_allowed_roles();
31 $this->registered_roles = wc_rbp_get_wp_roles();
32
33 $args = array();
34 $args['render_default'] = TRUE;
35 $args['html'] = '';
36 $args['postid'] = $id;
37 $args['mb'] = $this;
38 $args['parentID'] = isset($_REQUEST['parentID']) ? sanitize_text_field($_REQUEST['parentID']) : $id;
39 $args['selectedID'] = isset($_REQUEST['pid']) ? sanitize_text_field($_REQUEST['pid']) : $id;
40
41 $args = apply_filters_ref_array('wc_rbp_metabox_render', array( &$args ));
42
43 if( $args['render_default'] ) {
44 $render_info .= $this->render_default_metabox($id, $post, $args);
45 } else {
46 $render_info .= $args['html'];
47 }
48
49
50 $render_info .= '</div>';
51
52 echo $render_info;
53 }
54
55 public function get_post_type($id) {
56 $product_type = '';
57
58 if( $terms = wp_get_object_terms($id, 'product_type') ) {
59 $product_type = sanitize_title(current($terms)->name);
60 } else {
61 $product_type = apply_filters('default_product_type', 'simple');
62 }
63 return $product_type;
64 }
65
66 public function render_default_metabox($id, $post, $args, $type = 'default') {
67 $product_type = $this->get_post_type($id);
68
69 $render_info = '';
70 $post_type = get_post_type($id);
71
72 if( $product_type == 'variable' || $post_type == 'product_variation' ) {
73 $render_info .= $this->generate_variation_selectbox($args['parentID'], $id);
74 } else {
75 ob_start();
76 do_action("wc_rbp_metabox_header", $id, $product_type, $post, $this);
77 $render_info .= ob_get_contents();
78 ob_end_clean();
79 }
80
81 $prod = wc_get_product($id);
82 $prodType = 'simple';
83 if( is_object($prod) ) {
84 if( wc_rbp_is_wc_v('>=', '3.0.0') ) {
85 $prodType = $prod->get_type();
86 } else {
87 $prodType = $prod->product_type;
88 }
89 }
90
91 ob_start();
92 do_action('wc_rbp_before_metabox_content', $prod, $prodType);
93 $render_info .= ob_get_contents();
94 ob_end_clean();
95
96 $tabs = $this->get_metabox_tabs($id, $prodType);
97 $content = $this->get_metabox_content($id, $tabs, $prod, $prodType);
98
99 $render_info .= wc_rbp_generate_tabs($tabs, $content);
100 $render_info .= wc_rbp_get_editor_fields($type);
101 $render_info .= '<input type="hidden" id="wc_rbp_product_id" name="product_id" value="' . $id . '" /> ';
102
103 ob_start();
104 do_action('wc_rbp_after_metabox_content', $prod, $prodType);
105 $render_info .= ob_get_contents();
106 ob_end_clean();
107
108 $render_info .= $this->render_metabox_footer($id);
109
110 return $render_info;
111 }
112
113 public function generate_variation_selectbox($id, $selected = '') {
114
115 $header = $this->render_selectbox_header();
116 $args = array(
117 'post_type' => 'product_variation',
118 'post_status' => array( 'private', 'publish' ),
119 'posts_per_page' => -1,
120 'orderby' => array( 'menu_order' => 'ASC', 'ID' => 'DESC' ),
121 'post_parent' => $id,
122 'fields' => 'ids',
123 );
124
125 $variations = get_children($args);
126 $return = ' <optgroup label="' . __("Variations", WC_RBP_TXT) . '"> ';
127 foreach( $variations as $ids ) {
128 $prod = wc_get_product($ids);
129 $name = '#' . $ids . ' | ';
130
131 if( wc_rbp_is_wc_v('>=', '3.0') ) {
132 $name .= ' ' . wc_get_formatted_variation($prod, TRUE);
133 } else {
134 $name .= ' ' . $prod->get_formatted_variation_attributes(TRUE);
135 }
136
137
138 $selecteds = '';
139 if( $selected == $ids ) {
140 $selecteds = 'selected';
141 }
142 $return .= '<option data-type="variation" value="' . $ids . '" ' . $selecteds . '>' . $name . '</option>';
143 }
144 $return .= ' </optgroup> ';
145
146 $footer = $this->render_selectbox_footer();
147 $return = apply_filters("role_based_price_metabox_variation_select", $return, $selected, $id);
148 $return = $header . $return . $footer;
149 return $return;
150 }
151
152 public function render_selectbox_header($placeholder = '') {
153 if( empty($placeholder) ) {
154 $placeholder = __("Select A Variation : ", WC_RBP_TXT);
155 }
156 $header = '<select id="wc_rbp_variation_select" style="width: 30%; display: inline-block; vertical-align: middle; margin-left: 10px;" name="wc_rbp_variation_select" class="wcrbpvariationbx"> <option value="">' . $placeholder . '</option>';
157 return apply_filters("role_based_price_admin_selectbox_header", $header);
158 }
159
160 public function render_selectbox_footer() {
161 return apply_filters("role_based_price_admin_selectbox_header", '</select>');
162 }
163
164 public function get_metabox_tabs($id, $prodType) {
165 $tabs = apply_filters('wc_rbp_before_default_product_tabs', array(), $id, $prodType);
166 $registered_roles = $this->registered_roles;
167
168 foreach( $this->allowed_roles as $role ) {
169 if( isset($registered_roles[$role]) ) {
170 $icon = 'dashicons dashicons-admin-users';
171 $tabs[$role] = array(
172 'title' => $registered_roles[$role]['name'],
173 'icon' => $icon,
174 'show_status' => TRUE,
175 );
176 }
177 }
178
179 $tabs = apply_filters('wc_rbp_after_default_product_tabs', $tabs, $id, $prodType);
180 return $tabs;
181 }
182
183 public function get_metabox_content($id, $tabs, $prod, $prodType) {
184 $content = array();
185
186 foreach( $tabs as $tab_id => $val ) {
187 ob_start();
188 do_action('wc_rbp_price_edit_tab_' . $tab_id . '_before', $id, $prodType, $prod, $tab_id);
189 do_action('wc_rbp_price_edit_tab_' . $tab_id, $id, $prodType, $prod, $tab_id);
190 do_action('wc_rbp_price_edit_tab_' . $tab_id . '_after', $id, $prodType, $prod, $tab_id);
191
192 $content[$tab_id] = ob_get_contents();
193 ob_end_clean();
194 }
195
196 return $content;
197 }
198
199 public function render_metabox_footer($id) {
200 $base_price = $this->get_base_price($id);
201 $clbtn = '';
202 $product_type = wp_get_post_terms($id, 'product_type', array( 'fields' => 'names' ));
203
204 if( in_array('variable', $product_type) || get_post_type($id) == 'product_variation' ) {
205 $clbtn = '<button style="float:left;" type="button" id="wc_rbp_clear_trasient" class="button button-secondary">' . __('Clear Cache', WC_RBP_TXT) . '</button>';
206 }
207
208 return ' <h2 class="" style="margin: 0px -12px -12px; border-top: 1px solid #eee; text-align:right;">
209 <span class="wc_rbp_base_product_price">' . $base_price . '</span>
210 ' . $clbtn . '
211 <button type="button" id="wc_rbp_update_price" class="button button-primary">' . __('Save Price', WC_RBP_TXT) . '</button></h2> ';
212 }
213
214 public function get_base_price($id) {
215 $pro = wc_get_product($id);
216 $price = '';
217 if( is_object($pro) ) {
218 $price = array();
219 $this->hook_filter(TRUE);
220 $price['regular_price'] = wc_rbp_price_types('regular_price') . ' : ';
221 $price['regular_price'] .= wc_price($pro->get_regular_price());
222
223 $price['selling_price'] = wc_rbp_price_types('selling_price') . ' : ';
224 $price['selling_price'] .= wc_price($pro->get_sale_price());
225 $this->hook_filter(FALSE);
226 $price = implode(' | ', $price);
227 }
228 $head = '<span class="headTxt">' . __("WC Product Price : ") . '</span>' . $price;
229 return $head;
230 }
231
232 public function hook_filter($hook = TRUE) {
233 if( $hook == TRUE ) {
234 add_filter('role_based_price_status', array( $this, 'base_price_return_false' ));
235 }
236 if( ! $hook == TRUE ) {
237 remove_filter('role_based_price_status', array( $this, 'base_price_return_false' ));
238 }
239 }
240
241 public function base_price_return_false($s) {
242 return FALSE;
243 }
244
245 }
246
247 return new WooCommerce_Role_Based_Price_Product_Metabox;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Admin_Price_Editor_Fields {
15
16 public function __construct() {
17 add_action("wc_rbp_before_metabox_content", array( $this, 'register_price_fields' ));
18 add_filter('wc_rbp_before_default_product_tabs', array( $this, 'add_general_tab' ));
19 add_action('wc_rbp_price_edit_tab_general', array( $this, 'add_status_field' ), 10, 4);
20
21 }
22
23 public function add_general_tab($tabs) {
24 $tabs['general'] = array( 'title' => __('General', WC_RBP_TXT),
25 'icon' => 'dashicons-admin-tools',
26 'show_status' => FALSE,
27 );
28 return $tabs;
29 }
30
31 public function add_status_field($product_id, $prodType, $prod, $tab_id) {
32 $status = product_rbp_status($product_id) == 'true' ? 'checked' : '';
33 $content = '<div class="wc_rbp_price_container wc_rbp_popup_section wc_rbp_popup_section_' . $tab_id . '">';
34 $content .= '<div class="enable_field_container">';
35 $content .= '<p class="form-field ">';
36 $content .= '<label class="enable_text" for="enable_role_based_price">' . __('Enable Role Based Pricing', WC_RBP_TXT) . ' </label> ';
37 $content .= ' <input type="checkbox" data-secondaryColor="#999" data-size="small" class="wc_rbp_checkbox" id="enable_role_based_price" name="enable_role_based_price" ' . $status . '/> ';
38 $content .= '</p>';
39 $content .= '</div>';
40 $content .= '</div>';
41 echo $content;
42 }
43
44 public function register_price_fields() {
45 $allowed_roles = wc_rbp_allowed_roles();
46
47 foreach( $allowed_roles as $role ) {
48 add_action('wc_rbp_price_edit_tab_' . $role, array( $this, 'generate_price_field' ), 10, 4);
49 }
50 }
51
52 public function generate_price_field($product_id, $prodType, $prod, $tab_id) {
53 global $product;
54 $allowed_price = wc_rbp_allowed_price();
55 $price_exists = wc_rbp_price_types();
56 $output_html = '<div class="wc_rbp_price_container wc_rbp_popup_section wc_rbp_popup_section_' . $tab_id . '">';
57
58 foreach( $allowed_price as $price ) {
59 $field_id = 'role_based_price[' . $tab_id . '][' . $price . ']';
60 $defaults = array(
61 'type' => 'text',
62 'label' => $price_exists[$price],
63 'description' => __('Enter Product\'s ') . $price_exists[$price],
64 'class' => array(),
65 'label_class' => array(),
66 'input_class' => array( 'wc_input_price', $price, 'wc_rbp_' . $price ),
67 'return' => TRUE,
68 'custom_attributes' => array(),
69 );
70 $output_html .= '<div class="wc_rbp_pop_field_50 wc_rbp_pop_field_' . $price . '">';
71 $price = wc_rbp_price($product_id, $tab_id, $price);
72
73 $output_html .= woocommerce_form_field($field_id, $defaults, $price);
74 $output_html .= '</div>';
75 }
76 $output_html .= '</div>';
77 echo $output_html;
78 }
79
80
81 }
82
83 return new WooCommerce_Role_Based_Price_Admin_Price_Editor_Fields;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * WooCommerce Product Role Based Price Edit Functions
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Admin_Product_Functions {
15
16 public function __construct() {
17 add_action('wc_rbp_product_save_default', array( $this, 'simple_save_product_price' ), 1, 3);
18 }
19
20 public function simple_save_product_price(&$posted_values, &$success, &$error) {
21 $post_id = $posted_values['product_id'];
22
23 do_action_ref_array('wc_rbp_product_save_before', array( &$posted_values ));
24 if( isset($posted_values['role_based_price']) ) {
25 $status = isset($posted_values['enable_role_based_price']) ? TRUE : FALSE;
26 wc_rbp_update_role_based_price_status($post_id, $status);
27 wc_rbp_update_role_based_price($post_id, $posted_values['role_based_price']);
28 clean_post_cache($post_id);
29 $success['html'] = '<h3>' . __("Product Price Updated.", WC_RBP_TXT) . '</h3>';
30 } else {
31 $error['html'] = '<h3>' . __("Price Not Defined. Please Try Again", WC_RBP_TXT) . '</h3>';
32 }
33 do_action_ref_array('wc_rbp_product_save_after', array( &$posted_values ));
34 }
35 }
36
37 return new WooCommerce_Role_Based_Price_Admin_Product_Functions;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Class for registering settings and sections and for display of the settings form(s).
4 * For detailed instructions see: https://github.com/keesiemeijer/WP-Settings
5 *
6 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
7 * @package Role Based Price For WooCommerce
8 * @subpackage Role Based Price For WooCommerce/WordPress/Settings
9 * @since 3.0
10 * @version 2.0
11 * @author keesiemeijer
12 */
13 if( ! class_exists('WooCommerce_Role_Based_Price_Settings_WP_Fields') ) {
14 class WooCommerce_Role_Based_Price_Settings_WP_Fields {
15
16 public $version = 2.0;
17
18 /**
19 * Validated settings errors
20 *
21 * @since 0.1
22 *
23 * @var array
24 */
25 public $settings_errors;
26
27 /**
28 * constructor
29 */
30 public function __construct($errors = array()) {
31 $this->settings_errors = (array) $errors;
32 }
33
34
35 /**
36 * Displays a text input setting field.
37 *
38 * @param array $args
39 * @param string $type Type attribute
40 */
41 public function callback_text($args) {
42 $args['size'] = ( isset($args['size']) && $args['size'] ) ? $args['size'] : 'regular';
43 $type = ! empty($args['text_type']) ? esc_attr($args['text_type']) : 'text';
44 $args = $this->get_arguments($args); // escapes all attributes
45 $value = (string) esc_attr($this->get_option($args));
46 $error = $this->get_setting_error($args['id']);
47 $html = sprintf('<input type="%6$s" id="%1$s_%2$s" name="%1$s[%2$s]" value="%3$s"%4$s%5$s/>', $args['section'], $args['id'], $value, $args['attr'], $error, $type);
48
49 echo $args['before'] . $html . $args['after'] . $this->description($args['desc']);
50 }
51
52
53 /**
54 * Displays a textarea.
55 *
56 * @param array $args
57 */
58 public function callback_textarea($args) {
59 $size = ( isset($args['size']) && $args['size'] ) ? $args['size'] : 'regular';
60 $args = $this->get_arguments($args); // escapes all attributes
61 $value = (string) esc_textarea($this->get_option($args));
62 $error = $this->get_setting_error($args['id']);
63 $html = sprintf('<textarea id="%1$s_%2$s" name="%1$s[%2$s]"%4$s%5$s>%3$s</textarea>', $args['section'], $args['id'], $value, $args['attr'], $error);
64
65 echo $args['before'] . $html . $args['after'] . $this->description($args['desc']);
66 }
67
68 /**
69 * Displays a textarea.
70 *
71 * @param array $args
72 */
73 public function callback_richtext($args) {
74 $settings = isset($args['richtext_settings']) ? $args['richtext_settings'] : array();
75 $size = ( isset($args['size']) && $args['size'] ) ? $args['size'] : 'regular';
76 $args = $this->get_arguments($args); // escapes all attributes
77 $value = $this->get_option($args);
78 $error = $this->get_setting_error($args['id']);
79 $settings['textarea_name'] = $args['section'] . '[' . $args['id'] . ']';
80 $content = wp_editor($value, $args['id'], $settings);
81 echo $args['before'] . $content . $args['after'] . $this->description($args['desc']);
82 }
83
84
85 /**
86 * Displays a select dropdown.
87 *
88 * @param array $args
89 */
90 public function callback_select($args) {
91 $args = $this->get_arguments($args); // escapes all attributes
92 $value = array_map('esc_attr', array_values((array) $this->get_option($args)));
93 $multiple = ( preg_match('/multiple="multiple"/', strtolower($args['attr'])) ) ? '[]' : '';
94 $value = ( '[]' === $multiple ) ? $value : $value[0];
95 $html = sprintf('<select id="%1$s_%2$s" name="%1$s[%2$s]%4$s"%3$s>', $args['section'], $args['id'], $args['attr'], $multiple);
96
97 foreach( (array) $args['options'] as $opt => $label ) {
98 if( '[]' === $multiple ) {
99 $selected = ( in_array($opt, $value) ) ? ' selected="selected" ' : '';
100 } else {
101 $selected = selected($value, $opt, FALSE);
102 }
103 $html .= sprintf('<option value="%s"%s>%s</option>', $opt, $selected, $label);
104 }
105 $html .= sprintf('</select>');
106 echo $args['before'] . $html . $args['after'] . $this->description($args['desc']);
107 }
108
109
110 /**
111 * Displays a single checkbox.
112 *
113 * @param array $args
114 */
115 public function callback_checkbox($args) {
116 $args = $this->get_arguments($args); // escapes all attributes
117 $value = (string) esc_attr($this->get_option($args));
118 $error = $this->get_setting_error($args['id'], ' style="border: 1px solid red; padding: 2px 1em 2px 0; "');
119 $html = '';
120 $input = sprintf('<input type="checkbox" id="%1$s_%2$s" name="%1$s[%2$s]" value="on"%4$s%5$s />', $args['section'], $args['id'], $value, checked($value, 'on', FALSE), $args['attr']);
121 $html .= sprintf('<label for="%1$s_%2$s"%5$s>%3$s %4$s</label>', $args['section'], $args['id'], $input, $args['desc'], $error);
122
123 echo $html . '';
124 }
125
126
127 /**
128 * Displays multiple checkboxes.
129 *
130 * @param array $args
131 */
132 public function callback_multicheckbox($args) {
133 $args = $this->get_arguments($args); // escapes all attributes
134 $value = array_map('esc_attr', array_values((array) $this->get_option($args)));
135 $count = count($args['options']);
136 $html = '<fieldset>';
137 $i = 0;
138 foreach( (array) $args['options'] as $opt => $label ) {
139 $error = $this->get_setting_error($opt, ' style="border: 1px solid red; padding: 2px 1em 2px 0; "');
140 $checked = ( in_array($opt, $value) ) ? ' checked="checked" ' : '';
141 $input = sprintf('<input type="checkbox" id="%1$s_%2$s_%3$s" name="%1$s[%2$s][%3$s]" value="%3$s"%4$s%5$s />', $args['section'], $args['id'], $opt, $checked, $args['attr']);
142 $html .= sprintf('<label for="%1$s_%2$s_%4$s"%6$s>%3$s %5$s</label>', $args['section'], $args['id'], $input, $opt, $label, $error);
143 $html .= ( isset($args['row_after'][$opt]) && $args['row_after'][$opt] ) ? $args['row_after'][$opt] : '';
144 $html .= ( ++$i < $count ) ? '<br/>' : '';
145 }
146
147 echo $html . '</fieldset>' . $this->description($args['desc']);
148 }
149
150
151 /**
152 * Displays radio buttons.
153 *
154 * @param array $args
155 */
156 public function callback_radio($args) {
157 $args = $this->get_arguments($args); // escapes all attributes
158 $value = (string) esc_attr($this->get_option($args));
159 $options = array_keys((array) $args['options']);
160 // make sure one radio button is checked
161 if( empty($value) && ( isset($options[0]) && $options[0] ) ) {
162 $value = $options[0];
163 } else if( ! empty($value) && ( isset($options[0]) && $options[0] ) ) {
164 if( ! in_array($value, $options) )
165 $value = $options[0];
166 }
167 $html = '<fieldset>';
168 $i = 0;
169 $count = count($args['options']);
170 foreach( (array) $args['options'] as $opt => $label ) {
171 $input = sprintf('<input type="radio" id="%1$s_%2$s_%3$s" name="%1$s[%2$s]" value="%3$s"%4$s%5$s />', $args['section'], $args['id'], $opt, checked($value, $opt, FALSE), $args['attr']);
172 $html .= sprintf('<label for="%1$s_%2$s_%4$s">%3$s%5$s</label>', $args['section'], $args['id'], $input, $opt, ' <span>' . $label . '</span>');
173 $html .= ( isset($args['row_after'][$opt]) && $args['row_after'][$opt] ) ? $args['row_after'][$opt] : '';
174 $html .= ( ++$i < $count ) ? '<br/>' : '';
175 }
176
177 echo '</fieldset>' . $html . $this->description($args['desc']);
178 }
179
180
181 /**
182 * Displays type 'content' field.
183 *
184 * @param array $args
185 */
186 public function callback_content($args) {
187 if( isset($args['content']) )
188 echo $args['content'];
189 if( isset($args['desc']) )
190 echo $this->description($args['desc']);
191 }
192
193
194 /**
195 * Displays field with the action hook '{$page_hook}_add_extra_field'.
196 *
197 * @param array $args
198 */
199 function callback_extra_field($args) {
200 if( isset($args['callback']) && $args['callback'] ) {
201 if( isset($args['page_hook']) && $args['page_hook'] )
202 do_action($args['page_hook'] . '_add_extra_field', $args);
203 }
204 }
205
206
207 /**
208 * Returns a field description.
209 *
210 * @param string $desc Description of field.
211 */
212 public function description($desc = '') {
213 if( $desc ) {
214 //return sprintf( '<p class="description">%s</p>', $desc );
215 }
216 }
217
218
219 /**
220 * Returns validation errors for a settings field.
221 *
222 * @param string $setting_id Settings field ID.
223 * @param string $style Style to override the default error style.
224 *
225 * @return string Empty string or inline style attribute.
226 */
227 protected function get_setting_error($setting_id, $attr = '') {
228 $display_error = '';
229
230 if( ! empty($this->settings_errors) ) {
231 foreach( $this->settings_errors as $error ) {
232 if( isset($error['setting']) && $error['setting'] === $setting_id ) {
233 if( '' === $attr ) {
234 // todo: don't use inline styles
235 $display_error = ' style="border: 1px solid red;"';
236 } else {
237 $display_error = $attr;
238 }
239 }
240 }
241 }
242
243 return $display_error;
244 }
245
246
247 /**
248 * Escapes and creates additional attributes for a setting field.
249 *
250 * @param string|array $args Arguments of a setting field.
251 * @param string $input Type of field.
252 * @param string $size Size of field (class name).
253 *
254 * @return array All arguments and attributes
255 */
256 protected function get_arguments($args = '', $class = FALSE) {
257
258 // escape section, id and options used in attributes
259 $args['section'] = esc_attr($args['section']);
260 $args['id'] = esc_attr($args['id']);
261
262 if( isset($args['options']) && $args['options'] ) {
263 $options = array();
264 foreach( (array) $args['options'] as $key => $value ) {
265 $options[esc_attr($key)] = $value;
266 }
267 $args['options'] = $options;
268 }
269
270 // additional parameters
271 $attr_string = '';
272 $defaults = $attr = array();
273
274 if( isset($args['attr']) && $args['attr'] ) {
275 $attr = $args['attr'];
276 }
277
278 // set defaults for a textarea field
279 if( 'textarea' === $args['type'] ) {
280 $defaults = array( 'rows' => '5', 'cols' => '55' );
281 }
282
283 // todo: add action to add additional defaults
284
285 $attr['class'] = isset($attr['class']) ? trim($attr['class']) : '';
286
287 if( isset($args['size']) && $args['size'] ) {
288 if( 'text' === $args['type'] || 'textarea' === $args['type'] ) {
289 $attr['class'] .= sprintf(' %1$s-%2$s', $args['size'], $args['type']);
290 }
291 }
292
293
294 if( $class ) {
295 if( ! preg_match('/\s' . preg_quote((string) $class, '/') . '\s/', $attr['class']) ) {
296 $attr['class'] = ' ' . (string) $class;
297 }
298 }
299
300 if( '' === $attr['class'] ) {
301 unset($attr['class']);
302 }
303
304 // create attribute string
305 foreach( $attr as $key => $arg ) {
306 $arg = ( 'class' === $arg ) ? sanitize_html_class($arg) : esc_attr($arg);
307 $attr_string .= ' ' . trim($key) . '="' . trim($arg) . '"';
308 }
309
310 $args['attr'] = $attr_string;
311 return $args;
312 }
313
314
315 /**
316 * Returns the value of a setting field.
317 *
318 * @param array $args Arguments of setting field
319 *
320 * @return string
321 */
322 public function get_option($args) {
323
324 if( isset($args['value']) ) {
325 return $args['value'];
326 }
327
328 // get the value for the setting field from the database
329 $options = get_option($args['section']);
330
331 // return the value if it exists
332 if( isset($options[$args['id']]) ) {
333 return $options[$args['id']];
334 }
335
336 // return the default value
337 return ( isset($args['default']) ) ? $args['default'] : '';
338 }
339
340
341 } // class
342 } // class exists
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Admin_Settings_Options {
15
16 public function __construct() {
17 add_filter('wc_rbp_settings_pages', array( $this, 'settings_pages' ));
18 add_filter('wc_rbp_settings_section', array( $this, 'settings_section' ));
19 add_filter('wc_rbp_settings_fields', array( $this, 'settings_fields' ));
20 }
21
22 public function settings_pages($page) {
23 $page[] = array( 'id' => 'general', 'slug' => 'general', 'title' => __('General', WC_RBP_TXT) );
24 $page[] = array(
25 'id' => 'addonssettings',
26 'slug' => 'addonssettings',
27 'title' => __('Extensions Options', WC_RBP_TXT),
28 );
29 $page[] = array( 'id' => 'addons', 'slug' => 'wcrbpaddons', 'title' => __('Extensions', WC_RBP_TXT) );
30 return $page;
31 }
32
33 public function settings_section($section) {
34 $section['general'][] = array( 'id' => 'general', 'title' => __('General', WC_RBP_TXT) );
35 $section['addons'][] = array( 'id' => 'addons', 'title' => '' );
36 $addonSettings = array(
37 'addon_sample' => array(
38 'id' => 'addonssettings',
39 'title' => __('No Addons Activated / Installed.', WC_RBP_TXT),
40 ),
41 );
42 $addonSettings = apply_filters('wc_rbp_addon_sections', $addonSettings);
43
44 if( count($addonSettings) > 1 )
45 unset($addonSettings['addon_sample']);
46 $section['addonssettings'] = $addonSettings;
47 return $section;
48 }
49
50 public function settings_fields($fields) {
51 $fields['general']['general'][] = array(
52 'id' => WC_RBP_DB . 'allowed_roles',
53 'multiple' => 'true',
54 'type' => 'select',
55 'label' => __('Allowed User Roles', WC_RBP_TXT),
56 'desc' => __('User Roles To List In Product Edit Page', WC_RBP_TXT),
57 'options' => wc_rbp_sort_array_by_array(wc_rbp_get_user_roles_selectbox(), wc_rbp_allowed_roles()),
58 'attr' => array(
59 'class' => 'wc-rbp-enhanced-select',
60 'multiple' => 'multiple',
61 ),
62 );
63
64
65 $fields['general']['general'][] = array(
66 'id' => WC_RBP_DB . 'allowed_price',
67 'type' => 'select',
68 'multiple' => TRUE,
69 'label' => __('Allowed Product Pricing', WC_RBP_TXT),
70 'desc' => __('Price Fields To List In Product Edit Page', WC_RBP_TXT),
71 'options' => wc_rbp_sort_array_by_array(wc_rbp_avaiable_price_type(), wc_rbp_allowed_price()),
72 'attr' => array(
73 'class' => 'wc-rbp-enhanced-select',
74 'style' => 'width:auto;max-width:35%;',
75 'multiple' => 'multiple',
76 ),
77 );
78
79 $price_type = wc_rbp_avaiable_price_type();
80
81 foreach( $price_type as $pK => $pV ) {
82 $fields['general']['general'][] = array(
83 'id' => WC_RBP_DB . $pK . '_label',
84 'type' => 'text',
85 'label' => $pV . __(' Label ', WC_RBP_TXT),
86 'default' => $pV,
87 'attr' => array(
88 'style' => 'width:auto;max-width:35%;',
89 ),
90 );
91 }
92
93 if( class_exists('woocommerce_wpml') ) {
94 $fields['general']['general'][] = array(
95 'id' => WC_RBP_DB . 'enable_wpml_integration',
96 'type' => 'checkbox',
97 'label' => __('WPML Integration', WC_RBP_TXT),
98 'desc' => __('check if you have installed wpml and the price are showing wrong. ', WC_RBP_TXT),
99 'attr' => array( 'class' => 'wc_rbp_checkbox', ),
100 );
101 }
102
103
104 $addonSettings = array( 'addon_sample' => array() );
105 $addonSettings = apply_filters('wc_rbp_addon_fields', $addonSettings);
106 unset($addonSettings['addon_sample']);
107 $fields['addonssettings'] = $addonSettings;
108
109 return $fields;
110 }
111
112 }
113
114 return new WooCommerce_Role_Based_Price_Admin_Settings_Options;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Class for registering settings and sections and for display of the settings form(s).
4 * For detailed instructions see: https://github.com/keesiemeijer/WP-Settings
5 *
6 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
7 * @package Role Based Price For WooCommerce
8 * @subpackage Role Based Price For WooCommerce/WordPress/Settings
9 * @since 3.0
10 * @version 2.0
11 * @author keesiemeijer
12 */
13 if( ! defined('WPINC') ) {
14 die;
15 }
16
17 class WooCommerce_Role_Based_Price_Settings_Framework {
18 public $settings;
19 private $page_hook = '';
20 private $settings_page;
21 private $settings_section;
22 private $settings_fields;
23 private $create_function;
24 private $settings_key;
25 private $settings_values;
26
27 function __construct($page_hook = '') {
28 $this->settings_section = array();
29 $this->settings_fields = array();
30 $this->create_function = array();
31 $this->add_settings_pages();
32 //$this->get_settings();
33 $this->add_settings_section();
34 $this->create_callback_function();
35 $this->page_hook = $page_hook;
36
37 if( empty($page_hook) ) {
38 add_action('admin_menu', array( $this, 'admin_menu' ));
39 }
40 add_action('admin_init', array( $this, 'admin_init' ));
41 }
42
43 private function add_settings_pages() {
44 $pages = array();
45 $pages = apply_filters('wc_rbp_settings_pages', $pages);
46 $this->settings_page = $pages;
47 }
48
49 private function add_settings_section() {
50 $section = array();
51 $section = apply_filters('wc_rbp_settings_section', $section);
52 $this->settings_section = $section;
53 }
54
55 private function create_callback_function() {
56 $sec = $this->settings_section;
57
58 foreach( $sec as $sk => $s ) {
59 if( is_array($s) ) {
60 $c = count($s);
61 $a = 0;
62 while( $a < $c ) {
63 if( isset($s[$a]['validate_callback']) ) {
64 $this->create_function[] = $s[$a]['id'];
65 $s[$a]['validate_callback'] = '';
66 $file = addslashes(WC_RBP_SETTINGS . 'validate-' . $s[$a]['id'] . '.php');
67 $s[$a]['validate_callback'] = create_function('$fields', 'do_action("wc_rbp_settings_validate",$fields); do_action("wc_rbp_settings_validate_' . $s[$a]['id'] . '",$fields);');
68 }
69 $a++;
70 }
71 }
72
73 $this->settings_section[$sk] = $s;
74 }
75 }
76
77 function admin_menu() {
78 $this->page_hook = add_submenu_page('woocommerce', __('Role Based Price Settings', WC_RBP_TXT), __('Role Based Price Settings', WC_RBP_TXT), 'manage_woocommerce', WC_RBP_SLUG . '-settings', array(
79 $this,
80 'admin_page',
81 ));
82 }
83
84 function admin_init() {
85 $this->settings = new WooCommerce_Role_Based_Price_WP_Settings();
86 $this->add_settings_fields();
87 $this->settings->add_pages($this->settings_page);
88 $sections = $this->settings_section;
89
90 foreach( $sections as $page_id => $section_value ) {
91 $pages = $this->settings->add_sections($page_id, $section_value);
92 }
93
94 $fields = $this->settings_field;
95 foreach( $fields as $page_id => $section_fields ) {
96 foreach( $section_fields as $section_id => $sfields ) {
97 if( is_array($sfields) ) {
98 foreach( $sfields as $f ) {
99 $pages = $this->settings->add_field($page_id, $section_id, $f);
100 }
101
102 } else {
103 $pages = $this->settings->add_field($page_id, $section_id, $sfields);
104 }
105
106 }
107 }
108
109 $this->settings->init($pages, WC_RBP_DB);
110 }
111
112 private function add_settings_fields() {
113 global $fields;
114 $fields = array();
115 $fields = apply_filters('wc_rbp_settings_fields', $fields);
116 $this->settings_field = $fields;
117 }
118
119 public function admin_page() {
120 echo '<div class="wrap wc_rbp_settings">';
121 settings_errors();
122 $this->settings->render_header();
123 //echo $this->settings->debug;
124 $this->settings->render_form();
125 echo '</div>';
126 }
127
128 function get_option($id = '') {
129 if( ! empty($this->settings_values) && ! empty($id) ) {
130 if( isset($this->settings_values[$id]) ) {
131 return $this->settings_values[$id];
132 }
133 }
134 return FALSE;
135
136 }
137
138 function get_settings($key = '') {
139 $values = array();
140 foreach( $this->settings_page as $settings ) {
141 $this->settings_key[] = WC_RBP_DB . $settings['slug'];
142 $db_val = get_option(WC_RBP_DB . $settings['slug']);
143 if( is_array($db_val) ) {
144 unset($db_val['section_id']);
145 $values = array_merge($db_val, $values);
146 }
147 }
148
149 $this->settings_values = $values;
150 return $values;
151 }
152 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Class for registering settings and sections and for display of the settings form(s).
4 * For detailed instructions see: https://github.com/keesiemeijer/WP-Settings
5 *
6 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
7 * @package Role Based Price For WooCommerce
8 * @subpackage Role Based Price For WooCommerce/WordPress/Settings
9 * @since 3.0
10 * @version 2.0
11 * @author keesiemeijer
12 */
13 if( ! class_exists('WooCommerce_Role_Based_Price_WP_Settings') ) {
14 class WooCommerce_Role_Based_Price_WP_Settings {
15
16 /**
17 * Version of WP_Settings_Settings class
18 *
19 * @since 2.0
20 * @var
21 */
22 public $version = 2.0;
23
24 /**
25 * Current settings page.
26 *
27 * @since 2.0
28 * @var array
29 */
30 public $current_page = array();
31
32 /**
33 * Debug errors and notices.
34 *
35 * @since 2.0
36 * @var string
37 */
38 public $debug = '';
39
40 /**
41 * Admin pages.
42 *
43 * @since 2.0
44 * @var array
45 */
46 private $pages = array();
47
48 /**
49 * Admin pages.
50 *
51 * @since 2.0
52 * @var array
53 */
54 private $fields;
55
56 /**
57 * Unique plugin admin page hook suffix.
58 *
59 * @since 2.0
60 * @var array
61 */
62 private $page_hook;
63
64 /**
65 * Fields that need Javascript. (e.g. colorpicker)
66 *
67 * @since 2.0
68 * @var array
69 */
70 private $script_types;
71
72 /**
73 * Fields that need the label_argument in add_settings_field()
74 *
75 * @since 2.0
76 * @var array
77 */
78 private $label_for = array( 'text', 'select', 'textarea' );
79
80 /**
81 * array of Javascrips needed for the current settings page
82 *
83 * @since 2.0
84 * @var array
85 */
86 private $load_scripts = array();
87
88 /**
89 * Multiple forms on one settings page.
90 *
91 * @since 2.0
92 * @var bool
93 */
94 private $multiple_forms = FALSE;
95
96 /**
97 * valid admin pages and fields arrays.
98 *
99 * @since 2.0
100 * @var bool
101 */
102 private $valid_pages = FALSE;
103
104
105 /**
106 * Registers settings using the WorPres settings Api.
107 *
108 * @uses WP_Settings_Settings_Fields class
109 * @since 2.0 *
110 *
111 * @param array $pages Array with admin pages.
112 * @param string $page_hook Unique plugin admin page hook suffix.
113 */
114 public function init($pages, $page_hook = '') {
115
116 $this->pages = (array) $pages;
117 $this->page_hook = trim(sanitize_title((string) $page_hook));
118
119 // Debug strings don't use Gettext functions for translation.
120
121 if( ! class_exists('WooCommerce_Role_Based_Price_Settings_WP_Fields') ) {
122 $this->debug .= "Error: class WooCommerce_Role_Based_Price_Settings_WP_Fields doesn't exist<br/>";
123 }
124
125 if( '' === $this->page_hook ) {
126 $this->debug .= "Error: parameter 'page_hook' not provided in settings_admin_init()<br/>";
127 }
128
129 // Let external scripts do debugging .
130 $this->debug .= apply_filters("{$this->page_hook}_debug", $this->debug, $this->pages);
131
132 if( $this->debug ) {
133 return $this->valid_pages = FALSE; // Don't display the form and navigation.
134 }
135
136 // Passed validation (required to show form and navigation).
137 $this->valid_pages = TRUE;
138
139 $this->current_page = $this->get_current_admin_page();
140
141 if( isset($this->current_page['multiform']) && $this->current_page['multiform'] ) {
142 $this->multiple_forms = ( count($this->current_page['sections']) > 1 ) ? TRUE : FALSE;
143 }
144
145 // Instanciate the form fields.
146 $this->fields = new WooCommerce_Role_Based_Price_Settings_WP_Fields(get_settings_errors());
147
148 // Array of fields that needs the 'label_for' parameter (add_settings_field()).
149 $this->label_for = apply_filters("{$this->page_hook}_label_for", $this->label_for);
150
151 // Array of fields that needs javascript (e.g. 'color_picker').
152 $this->script_types = apply_filters("{$this->page_hook}_script_field_types", array());
153
154 $this->add_settings_sections();
155
156 // Register all the settings.
157 $this->register_settings();
158
159 // only load javascript if it's needed for the current admin page
160 if( ! empty($this->load_scripts) ) {
161 $this->load_scripts = array_unique($this->load_scripts);
162 add_action('admin_print_scripts-' . $this->page_hook, array( $this, 'enqueue_scripts' ));
163 }
164
165 } // admin_init()
166
167
168 /**
169 * Adds setting sections
170 *
171 * @since 2.0
172 * @return void
173 */
174 private function add_settings_sections() {
175
176 foreach( $this->current_page['sections'] as $section ) {
177
178 $section_description = '__return_false';
179
180 if( isset($section['desc']) && $section['desc'] ) {
181 $section_description = array( $this, 'render_section_description' );
182 }
183
184 $title = ( isset($section['title']) ) ? $section['title'] : ''; // optional
185
186 // Add page hook to sections and page ids.
187 $page_id = ( $this->multiple_forms ) ? $section['id'] : $this->current_page['id'];
188 $page_id = $this->page_hook . '' . $page_id;
189 $section_id = $this->page_hook . '' . $section['id'];
190
191 // Add database option(s) to debug messages.
192 $this->debug .= ( '' === $this->debug ) ? 'Database option(s) created for this page:<br/>' : '';
193 $this->debug .= "database option: " . $section_id . '<br/>'; // database option name
194
195 add_settings_section($section_id, $title, $section_description, $page_id);
196
197 if( isset($section['fields']) && ! empty($section['fields']) ) {
198
199 // Add fields to sections.
200 $this->add_settings_fields($section_id, $section['fields'], $page_id);
201 }
202 }
203 }
204
205
206 /**
207 * Adds all fields to a settings section.
208 *
209 * @since 2.0
210 *
211 * @param string $sections_id ID of section to add fields to.
212 * @param array $fields Array with section fields
213 * @param string $page_id Page id.
214 * @param bool $use_defaults Use default values for the settings fields.
215 */
216 private function add_settings_fields($sections_id, $fields, $page_id) {
217
218 $opt_defaults = array();
219 $defaults = array(
220 'section' => $sections_id,
221 'id' => '',
222 'type' => '',
223 'label' => '',
224 'desc' => '',
225 'size' => FALSE,
226 'options' => '',
227 'default' => '',
228 'content' => '',
229 'attr' => FALSE,
230 'before' => '',
231 'after' => '',
232 '_type' => '',
233 );
234
235 // Check if database option exist (use defaults if it doesn't).
236 $use_defaults = ( FALSE === get_option($sections_id) ) ? TRUE : FALSE;
237
238 foreach( $fields as $field ) {
239
240 // Field (rows) can be added by external scripts.
241 $multiple = ( isset($field['fields']) && $field['fields'] ) ? TRUE : FALSE;
242 $options = ( $multiple ) ? (array) $field['fields'] : array( $field );
243
244 foreach( $options as $key => $opt ) {
245
246 $args = wp_parse_args($opt, $defaults);
247
248 $args['default'] = ( $use_defaults ) ? $args['default'] : '';
249 $opt_defaults[$opt['id']] = $args['default'];
250
251 if( in_array($args['type'], $this->script_types) ) {
252 $this->load_scripts[] = $args['type']; // field needs javascript
253 }
254
255 if( in_array($args['type'], $this->label_for) ) {
256 $args['label_for'] = $sections_id . '' . $args['id'];
257 }
258
259 if( $multiple ) {
260 $field['fields'][$key] = $args;
261 }
262 }
263
264 if( $multiple ) {
265 $args = $field;
266 }
267
268 // ability to add fields with an action hook
269 if( ! method_exists($this->fields, 'callback_' . $field['type']) ) {
270 $args['callback'] = $field['type'];
271 $args['page_hook'] = $this->page_hook;
272 $field['type'] = 'extra_field';
273 }
274
275 if( method_exists($this->fields, 'callback_' . $field['type']) ) {
276 add_settings_field($sections_id . '[' . $field['id'] . ']', isset($args['label']) ? $args['label'] : '', array(
277 $this->fields,
278 'callback_' . $field['type'],
279 ), $page_id, $sections_id, $args);
280 }
281 }
282
283 // add the option or validation errors show twice on the first submit (todo: Why?).
284 if( $use_defaults ) {
285 add_option($sections_id, $opt_defaults);
286 }
287 }
288
289
290 /**
291 * Registers settings
292 *
293 * @since 2.0
294 * @return void
295 */
296 private function register_settings() {
297 foreach( $this->pages as $page ) {
298 foreach( $page['sections'] as $section ) {
299
300 // Use section ids for multiple forms.
301 if( isset($page['multiform']) && $page['multiform'] ) {
302 $page['id'] = ( count($page['sections']) > 1 ) ? $section['id'] : $page['id'];
303 }
304
305 $page_id = $this->page_hook . '' . $page['id'];
306 $sections_id = $this->page_hook . '' . $section['id'];
307
308 if( isset($section['validate_callback']) && $section['validate_callback'] ) {
309 register_setting($page_id, $sections_id, $section['validate_callback']);
310 } else {
311 register_setting($page_id, $sections_id);
312 }
313 }
314 }
315 }
316
317
318 /**
319 * Gets all settings from all sections
320 *
321 * @since 2.0
322 * @return array Array with settings.
323 */
324 public function get_settings($section = '') {
325 $settings = array();
326
327 if( ! empty($section) ) {
328 return get_option($this->page_hook . '' . $section);
329 }
330
331 foreach( (array) $this->pages as $page ) {
332 if( ! isset($page['sections']) ) {
333 continue;
334 }
335
336 foreach( $page['sections'] as $section ) {
337 if( ! isset($section['id']) ) {
338 continue;
339 }
340
341 $option = get_option($this->page_hook . '' . $section['id']);
342 if( $option ) {
343 unset($option['section_id']);
344 $settings[$section['id']] = $option;
345 }
346 }
347 }
348
349 return $settings;
350 }
351
352
353 /**
354 * Returns the current settings page.
355 *
356 * @since 2.0
357 *
358 * @param array $admin_pages . Array of settings pages.
359 *
360 * @return array Current settings page.
361 */
362 public function get_current_admin_page() {
363
364 foreach( (array) $this->pages as $page ) {
365 if( isset($_GET['tab']) && $_GET['tab'] ) {
366 if( ( $_GET['tab'] === $page['id'] ) || ( $_GET['tab'] === $page['slug'] ) )
367 $current_page = $page;
368 }
369 }
370
371 // Set the first settings page as current if it's not a tab.
372 if( empty($current_page) ) {
373 $current_page = $this->pages[0];
374 }
375
376 return $current_page;
377 }
378
379
380 /**
381 * Adds a admin page.
382 *
383 * @since 2.0
384 *
385 * @param array $page Page array.
386 *
387 * @return array Admin pages array with the page added.
388 */
389 public function add_page($page) {
390 return $this->pages[] = $page;
391 }
392
393
394 /**
395 * Adds multiple admin pages.
396 *
397 * @since 2.0
398 *
399 * @param array $pages Array with pages.
400 *
401 * @return array Admin pages array with the pages added.
402 */
403 public function add_pages($pages) {
404 foreach( $pages as $page ) {
405 $this->add_page($page);
406 }
407 return $this->pages;
408 }
409
410
411 /**
412 * Adds a section to an admin page.
413 *
414 * @since 2.0
415 *
416 * @param string $page Page id.
417 * @param array $section Section array.
418 *
419 * @return array Admin pages array with the section added.
420 */
421 public function add_section($page, $section) {
422
423 foreach( $this->pages as $key => $_page ) {
424
425 if( $page !== $_page['id'] ) {
426 continue;
427 }
428
429 if( isset($this->pages[$key][$page]['sections']) ) {
430 $this->pages[$key]['sections'] = array();
431 }
432
433 $this->pages[$key]['sections'][] = $section;
434 }
435
436 return $this->pages;
437 }
438
439
440 /**
441 * Adds multiple sections to an admin page.
442 *
443 * @since 2.0
444 *
445 * @param array $string Page id
446 * @param array $sections Array with sections.
447 *
448 * @return array Admin pages array with the sections added.
449 */
450 public function add_sections($page, $sections) {
451 foreach( $sections as $section ) {
452 $this->pages = $this->add_section($page, $section);
453 }
454 return $this->pages;
455 }
456
457
458 /**
459 * Adds a form field to a section.
460 *
461 * @since 2.0
462 *
463 * @param string $page Page id.
464 * @param string $section Section id.
465 * @param array $field Field array.
466 *
467 * @return array Admin pages array with the field added.
468 */
469 public function add_field($page, $section, $field) {
470
471 foreach( $this->pages as $key => $_page ) {
472
473 if( $page !== $_page['id'] ) {
474 continue;
475 }
476
477 if( ! isset($this->pages[$key]['sections']) ) {
478 continue;
479 }
480
481 $_sections = $this->pages[$key]['sections'];
482
483 foreach( $_sections as $_key => $_section ) {
484
485 if( $section !== $_section['id'] ) {
486 continue;
487 }
488
489 if( ! isset($this->pages[$key]['sections'][$_key]['fields']) ) {
490 $this->pages[$key]['sections'][$_key]['fields'] = array();
491 }
492
493 $this->pages[$key]['sections'][$_key]['fields'][] = $field;
494 }
495 }
496
497 return $this->pages;
498 }
499
500
501 /**
502 * Adds multiple form fields to a section.
503 *
504 * @since 2.0
505 *
506 * @param string $page Page id.
507 * @param string $section Section id.
508 * @param array $fields Array with fields.
509 *
510 * @return array Admin pages array with the fields added.
511 */
512 public function add_fields($page, $section, $fields) {
513 foreach( $fields as $field ) {
514 $this->pages = $this->add_field($page, $section, $field);
515 }
516 return $this->pages;
517 }
518
519
520 /**
521 * Enqueue javascript for fields that need them.
522 *
523 * @since 2.0
524 * @return void
525 */
526 public function enqueue_scripts() {
527 $screen = get_current_screen();
528
529 // Only load scripts on plugin pages.
530 if( $screen->id === $this->page_hook ) {
531 do_action("{$this->page_hook}_scripts", $this->load_scripts);
532 }
533 }
534
535
536 /**
537 * Display the description of a section.
538 *
539 * @since 2.0
540 *
541 * @param array $section Description of section.
542 *
543 * @return void
544 */
545 public function render_section_description($section) {
546 foreach( $this->current_page['sections'] as $setting ) {
547 if( $this->page_hook . '' . $setting['id'] === $section['id'] )
548 echo sprintf('<p class="section_desc">%s</p>', $setting['desc']);
549 }
550 }
551
552
553 /**
554 * Display Plugin Title and if needed tabbed navigation.
555 *
556 * @since 2.0
557 *
558 * @param string $plugin_title Plugin title.
559 * @param string $tab_id Page id. Manually set the active tab.
560 *
561 * @return void
562 */
563 public function render_header($plugin_title = '', $tab_id = FALSE) {
564
565 if( ! empty($plugin_title) )
566 echo get_screen_icon() . '<h2>' . (string) $plugin_title . '</h2>';
567
568 // if ( !$this->valid_pages )
569 // return;
570
571 $page_title_count = 0;
572
573 foreach( $this->pages as $page ) {
574 if( isset($page['title']) && $page['title'] )
575 ++$page_title_count;
576 }
577
578 $html = '';
579 $current = $this->current_page;
580 $page_ids = wp_list_pluck($this->pages, 'id');
581 $cur_tab_id = ( $tab_id ) ? (string) $tab_id : $current['id'];
582 $cur_tab_id = ( in_array($cur_tab_id, $page_ids) ) ? $cur_tab_id : $current['id'];
583 $i = 0;
584
585 foreach( $this->pages as $page ) {
586
587 if( ( isset($page['title']) && $page['title'] ) ) {
588 if( $page_title_count > 1 ) {
589 $html .= ( 0 === $i ) ? '<h2 class="nav-tab-wrapper">' : '';
590
591 $active = '';
592 if( $cur_tab_id === $page['id'] )
593 $active = ' nav-tab-active';
594
595 // Get the url of the current settings page.
596 $tab_url = remove_query_arg(array( 'tab', 'settings-updated' ));
597
598 // Add query arg 'tab' if it's not the first settings page.
599 if( $this->pages[0]['id'] !== $page['id'] )
600 $tab_url = add_query_arg('tab', $page['slug'], $tab_url);
601
602 $html .= sprintf('<a href="%1$s" class="nav-tab%2$s" id="%3$s-tab">%4$s</a>', esc_url($tab_url), $active, esc_attr($page['id']), $page['title']);
603
604 $html .= ( ++$i === $page_title_count ) ? '</h3>' : '';
605 }
606
607 if( $page_title_count === 1 ) {
608 if( isset($current['title']) && $current['title'] === $page['title'] ) {
609 $html .= '<h3>' . $page['title'] . '</h3>';
610 break;
611 }
612 }
613
614 }
615 }
616
617 echo $html;
618 } // render_header()
619
620
621 /**
622 * Prints out all settings sections added to a particular settings page
623 *
624 * Part of the Settings API. Use this in a settings page callback function
625 * to output all the sections and fields that were added to that $page with
626 * add_settings_section() and add_settings_field()
627 *
628 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
629 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
630 * @since 2.7.0
631 *
632 * @param string $page The slug name of the page whose settings sections you want to output
633 */
634 function do_settings_sections($page) {
635 global $wp_settings_sections, $wp_settings_fields;
636
637 if( ! isset($wp_settings_sections[$page]) )
638 return;
639 $section_count = count($wp_settings_sections[$page]);
640 if( $section_count > 1 ) {
641 echo '<ul class="subsubsub wc_rbp_settings_submenu">';
642 foreach( (array) $wp_settings_sections[$page] as $section ) {
643 echo '<li> <a href="#' . $section['id'] . '">' . $section['title'] . '</a> | </li>';
644 }
645 echo '</ul> <br/>';
646 }
647
648 foreach( (array) $wp_settings_sections[$page] as $section ) {
649 if( $section_count > 1 ) {
650 echo '<div id="settings_' . $section['id'] . '" class="hidden wc_rbp_settings_content">';
651 }
652
653 if( $section['title'] )
654 echo "<h2>{$section['title']}</h2>\n";
655
656 if( $section['callback'] )
657 call_user_func($section['callback'], $section);
658
659 if( ! isset($wp_settings_fields) || ! isset($wp_settings_fields[$page]) || ! isset($wp_settings_fields[$page][$section['id']]) )
660 continue;
661 echo '<table class="wc_rbp_settings_table">';
662 $this->do_settings_fields($page, $section['id']);
663 echo '</table>';
664 if( $section_count > 1 ) {
665 echo '</div>';
666 }
667 }
668 }
669
670 /**
671 * Print out the settings fields for a particular settings section
672 *
673 * Part of the Settings API. Use this in a settings page to output
674 * a specific section. Should normally be called by do_settings_sections()
675 * rather than directly.
676 *
677 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
678 *
679 * @since 2.7.0
680 *
681 * @param string $page Slug title of the admin page who's settings fields you want to show.
682 * @param string $section Slug title of the settings section who's fields you want to show.
683 */
684 function do_settings_fields($page, $section) {
685 global $wp_settings_fields;
686
687 if( ! isset($wp_settings_fields[$page][$section]) )
688 return;
689
690 foreach( (array) $wp_settings_fields[$page][$section] as $field ) {
691 $class = '';
692
693 if( ! empty($field['args']['class']) ) {
694 $class = ' class="' . esc_attr($field['args']['class']) . '"';
695 }
696
697 echo "<tr{$class}>";
698 $desc = sprintf('<p class="description">%s</p>', $field['args']['desc']);
699 if( ! empty($field['args']['label_for']) ) {
700 echo '<th scope="row"><label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . $desc . '</label></th>';
701 } else {
702 echo '<th scope="row">' . $field['title'] . $desc . '</th>';
703 }
704
705 echo '<td>';
706 call_user_func($field['callback'], $field['args']);
707 echo '</td>';
708 echo '</tr>';
709 }
710 }
711
712
713 /**
714 * Displays the form(s) and sections.
715 *
716 * @since 2.0
717 * @return void
718 */
719 public function render_form() {
720
721 if( ! $this->valid_pages ) {
722 return;
723 }
724
725 $page = $this->current_page;
726
727 if( ! empty($page) ) {
728
729 $ids = wp_list_pluck($page['sections'], 'id');
730 $forms = ( $this->multiple_forms ) ? $page['sections'] : array( $page );
731
732 // Section ids hidden inputs.
733 $section_ids = '';
734 foreach( $ids as $id ) {
735 $section_ids .= "<input id='{$this->page_hook}_{$id}_section_id' type='hidden' value='{$id}' name='{$this->page_hook}_{$id}[section_id]'>";
736 }
737
738 foreach( $forms as $form ) {
739
740 echo '<form method="post" action="options.php">';
741 // print hidden section_id fields
742 echo $section_ids;
743
744 // lets you add additional fields
745 echo apply_filters("{$this->page_hook}_form_fields", '', $form['id'], $form);
746
747 settings_fields($this->page_hook . '' . $form['id']);
748 $this->do_settings_sections($this->page_hook . '' . $form['id']);
749
750 $submit = ( isset($form['submit']) && $form['submit'] ) ? $form['submit'] : '';
751
752 if( ( '' === $submit ) && isset($page['submit']) && $page['submit'] ) {
753 $submit = $page['submit'];
754 }
755
756 $text = isset($submit['text']) ? $submit['text'] : NULL;
757 $type = isset($submit['$type']) ? $submit['text'] : 'primary';
758 $name = isset($submit['$name']) ? $submit['name'] : 'submit';
759 $other_attributes = array( 'id' => $form['id'] );
760
761 submit_button($text, $type, $name, TRUE, $other_attributes);
762 echo '</form>';
763 }
764 }
765 } // render_form()
766
767 } // class
768 } // class exists
...\ No newline at end of file ...\ No newline at end of file
1 </div></div>
...\ No newline at end of file ...\ No newline at end of file
1 <?php echo $category; ?>
2 <div class="wp-list-table widefat plugin-install">
3 <div class="the-list wc_rbp_addon_listing">
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 $slug = $wc_rbp_plugin_data['addon_slug'];
3 $cat_slug = implode(' wc-rbp-addon-', array_keys($wc_rbp_plugin_data['Category']));
4
5 $wrapperClass = 'plugin-card plugin-card-' . $slug . ' wc-rbp-addon-all wc-rbp-addon-' . $cat_slug;
6
7 if( $wc_rbp_plugin_data['is_active'] ) {
8 $wrapperClass .= ' wc-rbp-addon-active';
9 } else {
10 $wrapperClass .= ' wc-rbp-addon-inactive';
11 }
12
13 ?>
14 <div class="<?php echo $wrapperClass; ?>" id="<?php echo $slug; ?>">
15 <?php wc_rbp_get_ajax_overlay(); ?>
16 <div class="plugin-card-top">
17 <div class="name column-name">
18 <h3>
19 <?php echo $wc_rbp_plugin_data['Name']; ?>
20 [
21 <small><?php _e('V', WC_RBP_TXT); ?><?php echo $wc_rbp_plugin_data['Version']; ?></small>
22 ]
23 <?php $this->get_addon_icon($wc_rbp_plugin_data); ?>
24 </h3>
25 </div>
26 <div class="desc column-description">
27 <p><?php echo $wc_rbp_plugin_data['Description']; ?></p>
28 <p class="authors">
29
30 <cite>
31 <?php _e('By', WC_RBP_TXT); ?>
32 <a href="<?php echo $wc_rbp_plugin_data['AuthorURI']; ?>"> <?php echo $wc_rbp_plugin_data['Author']; ?></a>
33 </cite>
34 </p>
35 </div>
36 </div>
37 <div class="plugin-card-top wc-rbp-addons-required-plugins">
38 <?php if( ! empty($required_plugins) ): ?>
39 <div>
40 <h3><?php _e('Required Plugins :', WC_RBP_TXT); ?></h3>
41 <ul>
42 <?php
43 $echo = '';
44 foreach( $required_plugins as $plugin ) {
45 $plugin_status = $this->check_plugin_status($plugin['Slug']);
46 $status_val = __('InActive', WC_RBP_TXT);
47 $class = 'deactivated';
48 if( $plugin_status === 'notexist' ) {
49 $status_val = __('Plugin Does Not Exist', WC_RBP_TXT);
50 $class = 'notexist';
51 } else if( $plugin_status === TRUE ) {
52 $status_val = __('Active', WC_RBP_TXT);
53 $class = 'active';
54 }
55 if( ! isset($plugin['Version']) ) {
56 $plugin['version'] = '';
57 }
58 echo '<li class="' . $class . '">';
59
60 echo '<span class="wc_rbp_required_addon_plugin_name"> <a href="' . $plugin['URL'] . '" > ' . $plugin['Name'] . ' [' . $plugin['Version'] . '] </a> </span> : ';
61 echo '<span class="wc_rbp_required_addon_plugin_status ' . $class . '">' . $status_val . '</span>';
62 echo '</li>';
63 unset($plugin_status);
64 }
65 ?>
66 </ul>
67 <?php /*<p> <span><?php _e('Above Mentioned Plugin name with version are Tested Up to',WC_RBP_TXT);?></span> </p> */ ?>
68
69 </div>
70 <?php endif; ?>
71
72 <?php if( ! empty($wc_rbp_plugin_data['screenshots']) ) : ?>
73 <div class="addon-screenshots">
74 <h3><?php _e("Screenshots", WC_RBP_TXT); ?></h3>
75 <ul>
76 <?php
77 $i = 1;
78 $url = $wc_rbp_plugin_data['addon_url'];
79 foreach( $wc_rbp_plugin_data['screenshots'] as $screen ) {
80 echo '<li><a class="thickbox" href="' . $url . basename($screen) . '?TB_iframe=true">' . $i . '</a></li>';
81 $i++;
82 }
83 ?>
84 </ul>
85 </div>
86
87 <?php endif; ?>
88
89 <small><strong><?php _e('Addon Slug : ', WC_RBP_TXT); ?></strong><?php echo $wc_rbp_plugin_slug; ?></small>
90 </div>
91 <div class="plugin-card-bottom">
92 <div class="column-updated" data-pluginslug="<?php echo $slug; ?>">
93 <?php echo $this->get_addon_action_button($wc_rbp_plugin_slug, $required_plugins); ?>
94 </div>
95 <div class="column-downloaded"><strong><?php _e('Last Updated:', WC_RBP_TXT); ?></strong>
96 <span title="<?php echo $wc_rbp_plugin_data['last_update']; ?>"><?php echo $wc_rbp_plugin_data['last_update']; ?></span>
97 </div>
98 <div class="column-downloaded wc_rbp_ajax_response"></div>
99 </div>
100 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <div class="wc_rbp_price_editor_footer">
2 <p>
3 <button name="close" onclick="Custombox.close();" id="close_modal"
4 class="button button-secondary"> <?php _e('Close', WC_RBP_TXT); ?> </button>
5 <button name="update_price" id="update_price"
6 class="button button-primary"> <?php _e('Update Price', WC_RBP_TXT); ?> </button>
7 </p>
8 </div>
9 </div>
10 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <div class="wc-rbp-modal wc-rbp-modal-ajax" style="display: block;">
2 <button type="button" class="close" onclick="Custombox.close();"><span>&times;</span></button>
3 <h4 class="title"><?php _e('Role Based Price Editor'); ?> </h4>
4 <div class="wc-rbp-modal-content text">
5
6
...\ No newline at end of file ...\ No newline at end of file
1 <?php global $type, $product_id; ?>
2
3 <div class="wc_rbp_price_editor_fields" style="display:none;">
4 <form method="post" action="<?php echo admin_url('admin-ajax.php'); ?>" id="wc_rbp_price_editor_form">
5 <div class="wc_rbp_hidden_fields">
6 <?php echo wc_rbp_get_editor_fields($type); ?>
7 </div>
8 <div class="hide hidden wc_rbp_price_editor_ajax_response"></div>
9 <?php
10
11 $tabs = array();
12 $allowed_roles = wc_rbp_allowed_roles();
13 $registered_roles = wc_rbp_get_wp_roles();
14
15 foreach( $allowed_roles as $role ) {
16 if( isset($registered_roles[$role]) ) {
17 $tabs[$role] = $registered_roles[$role]['name'];
18 }
19 }
20
21 $tabs = apply_filters('wc_rbp_price_editor_tabs', $tabs, $product_id, $type);
22 $tab_pos = wc_rbp_option('price_editor_tab_pos');
23 extract(wc_rbp_get_tab_pos($tab_pos));
24
25 if( $type == 'simple' ) {
26 echo '<input type="hidden" name="product_id" value="' . $product_id . '" /> ';
27 }
28
29 do_action('wc_rbp_price_edit_top', $product_id, $type);
30 echo '<div class="tab_container">';
31 echo '<div class="wc_rbp_tabs" data-tabsPosition="' . $tab_pos . '"
32 data-horizontalPosition="' . $horizontalPosition . '"
33 data-verticalPosition="' . $verticalPosition . '">';
34
35 foreach( $tabs as $tabID => $name ) {
36 echo '<div data-pws-tab-name="' . $name . '" data-pws-tab="' . $tabID . '" class="pws_hide pws_tab_single" data-pws-tab-id="' . $tabID . '">';
37 do_action('wc_rbp_price_edit_tab_before', $product_id, $type, $tabID);
38 do_action('wc_rbp_price_edit_tab_' . $tabID . '_before', $product_id, $type, $tabID);
39 do_action('wc_rbp_price_edit_tab_' . $tabID, $product_id, $type, $tabID);
40 do_action('wc_rbp_price_edit_tab_' . $tabID . '_after', $product_id, $type, $tabID);
41 do_action('wc_rbp_price_edit_tab_after', $product_id, $type, $tabID);
42 echo '</div>';
43 }
44
45 echo '</div>';
46 echo '</div>';
47 do_action('wc_rbp_price_edit_bottom', $product_id, $type);
48 ?>
49 </form>
50 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <div class="wrap about-wrap">
2 <h1><?php _e("Welcome To", WC_RBP_TXT);
3 echo ' ' . __("Role Based Price For WooCommerce", WC_RBP_TXT) . ' ' . WC_RBP_V; ?></h1>
4 <p class="about-text">
5 <?php echo WC_RBP_NAME;
6 _e(" now with improved speed and stability"); ?>
7 </p>
8 <div class="wp-badge"><?php echo WC_RBP_V; ?></div>
9 </div>
10
11
12 <style>
13 .wp-badge {
14 background-image : url("https://plugins.svn.wordpress.org/woocommerce-role-based-price/assets/icon-256x256.jpg") !important;
15 background-position : center top !important;
16 background-size : 100% auto !important;
17 padding-top : 140px !important;
18 padding-bottom : 3px !important;
19 height : auto !important;
20 }
21 </style>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Addons {
15
16 public function __construct() {
17 add_action('wp_ajax_wc_rbp_get_addons_html', array( $this, 'list_addons_ajax' ));
18 add_action(WC_RBP_DB . '_form_fields', array( $this, 'list_addons' ), 10, 2);
19 add_action('wp_ajax_wc_rbp_activate_addon', array( $this, 'activate_plugin' ));
20 add_action('wp_ajax_wc_rbp_deactivate_addon', array( $this, 'deactivate_plugin' ));
21 }
22
23 public function list_addons_ajax() {
24 $this->list_addons('', 'addons');
25 }
26
27 public function list_addons($none, $form_id) {
28 if( $form_id != 'addons' ) {
29 return;
30 }
31 $this->plugins_data = $this->search_and_get_addons();
32 $this->generate_view();
33 }
34
35 public function search_and_get_addons() {
36 $search_dirs = apply_filters('wc_rbp_addons_dir', array());
37 $addons_others = array();
38 $internal_addons = $this->get_plugins(WC_RBP_PLUGIN);
39
40 if( ! empty($search_dirs) ) {
41 foreach( $search_dirs as $dir ) {
42 $dir_addons = $this->get_plugins($dir);
43 $addons_others = array_merge($addons_others, $dir_addons);
44 unset($dir_addons);
45 }
46 }
47
48 $return = array_merge($internal_addons, $addons_others);
49 return $return;
50 }
51
52 /**
53 * Check the plugins directory and retrieve all plugin files with plugin data.
54 * The file with the plugin data is the file that will be included and therefore
55 * needs to have the main execution for the plugin. This does not mean
56 * everything must be contained in the file and it is recommended that the file
57 * be split for maintainability. Keep everything in one file for extreme
58 * optimization purposes.
59 *
60 * @since 1.5.0
61 *
62 * @param string $plugin_folder Optional. Relative path to single plugin folder.
63 *
64 * @return array Key is the plugin file path and the value is an array of the plugin data.
65 */
66 public function get_plugins($plugin_folder = '') {
67 $wp_plugins = array();
68 $plugin_root = WC_RBP_PLUGIN;
69 if( ! empty($plugin_folder) ) {
70 $plugin_root = $plugin_folder;
71 }
72 $plugins_dir = @ opendir($plugin_root);
73 $plugin_files = array();
74
75 if( $plugins_dir ) {
76 while( ( $file = readdir($plugins_dir) ) !== FALSE ) {
77 if( substr($file, 0, 1) == '.' ) {
78 continue;
79 }
80 if( is_dir($plugin_root . '/' . $file) ) {
81 $plugins_subdir = @ opendir($plugin_root . '/' . $file);
82 if( $plugins_subdir ) {
83 while( ( $subfile = readdir($plugins_subdir) ) !== FALSE ) {
84 if( substr($subfile, 0, 1) == '.' ) {
85 continue;
86 }
87 if( substr($subfile, -4) == '.php' ) {
88 $plugin_files[] = "$file/$subfile";
89 }
90 }
91 closedir($plugins_subdir);
92 }
93 } else {
94 if( substr($file, -4) == '.php' ) {
95 $plugin_files[] = $file;
96 }
97 }
98 }
99 closedir($plugins_dir);
100 }
101
102 if( empty($plugin_files) ) {
103 return $wp_plugins;
104 }
105 foreach( $plugin_files as $plugin_file ) {
106 if( ! is_readable("$plugin_root/$plugin_file") ) {
107 continue;
108 }
109 $plugin_data = $this->get_plugin_data("$plugin_root/$plugin_file", FALSE, TRUE);
110
111 $plugin_base = $plugin_root . dirname($plugin_file);
112
113
114 if( empty ($plugin_data['Name']) ) {
115 continue;
116 }
117 $is_active = wc_rbp_check_active_addon("$plugin_file");
118 $plugin_data["is_active"] = $is_active;
119 $plugin_data["installed"] = TRUE;
120
121 $plugin_data["addon_root"] = $plugin_root . dirname($plugin_file) . '/';
122 $plugin_data["addon_url"] = plugin_dir_url("$plugin_root/$plugin_file");
123 $plugin_data["addon_slug"] = sanitize_title(dirname($plugin_file));
124 $plugin_data["addon_folder"] = dirname($plugin_file) . '/';
125 $plugin_data['screenshots'] = glob($plugin_base . '/screenshot*.*');
126 $wp_plugins[plugin_basename($plugin_file)] = $plugin_data;
127 }
128
129 return $wp_plugins;
130 }
131
132 /**
133 * Parses the plugin contents to retrieve plugin's metadata.
134 * The metadata of the plugin's data searches for the following in the plugin's
135 * header. All plugin data must be on its own line. For plugin description, it
136 * must not have any newlines or only parts of the description will be displayed
137 * and the same goes for the plugin data. The below is formatted for printing.
138 *
139 * ** Plugin Name: Name of the plugin
140 * ** Plugin Icon: (Icon URL / DATA Code)
141 * ** Description: some Description about plugin
142 * ** Version: 01
143 * ** Author: Author Name
144 * ** Author URL: Author URL
145 * ** Last Update: YYYY-MM-DD
146 * ** Required Plugins: plugin-folder/plugin-file.php | Version , plugin-folder/plugin-file.php | 2.0*
147 *
148 * @param string $plugin_file Path to the plugin file
149 * @param bool $markup Optional. If the returned data should have HTML markup applied. Default true.
150 * @param bool $translate Optional. If the returned data should be translated. Default true.
151 */
152 public function get_plugin_data($plugin_file, $markup = TRUE, $translate = TRUE) {
153 $default_headers = array(
154 'Name' => 'Plugin Name',
155 'PluginURI' => 'Plugin URI',
156 'icon' => 'Plugin Icon',
157 'Version' => 'Version',
158 'Description' => 'Description',
159 'Author' => 'Author',
160 'AuthorURI' => 'Author URI',
161 'last_update' => 'Last Update',
162 'rplugins' => 'Required Plugins',
163 'Category' => 'Category',
164 );
165
166 $plugin_data = get_file_data($plugin_file, $default_headers, 'wc_rbp_plugin');
167
168 if( empty($plugin_data['TextDomain']) ) {
169 $plugin_data['TextDomain'] = WC_RBP_TXT;
170 }
171 if( empty($plugin_data['DomainPath']) ) {
172 $plugin_data['DomainPath'] = FALSE;
173 }
174 if( empty($plugin_data['Category']) ) {
175 $plugin_data['Category'] = 'general';
176 }
177
178 $cat = explode(',', $plugin_data['Category']);
179
180 $plugin_data['Category'] = array();
181 foreach( $cat as $c ) {
182 $key = sanitize_key($c);
183 $plugin_data['Category'][$key] = $c;
184 }
185
186 if( $markup || $translate ) {
187 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
188 } else {
189 $plugin_data['Title'] = $plugin_data['name'];
190 $plugin_data['AuthorName'] = $plugin_data['author'];
191 }
192
193 return $plugin_data;
194 }
195
196 public function generate_view() {
197 $category = $this->get_addon_category();
198 $category = $this->get_html_addon_category($category);
199 include( WC_RBP_ADMIN . 'views/addons-header.php' );
200 foreach( $this->plugins_data as $addon_slug => $data ) {
201 $wc_rbp_plugin_data = $data;
202 $wc_rbp_plugin_slug = $addon_slug;
203 $required_plugins = $this->extract_required_plugins($wc_rbp_plugin_data);
204 include( WC_RBP_ADMIN . 'views/addons-single.php' );
205 unset($wc_rbp_plugin_data);
206 }
207 include( WC_RBP_ADMIN . 'views/addons-footer.php' );
208 }
209
210 public function get_addon_category() {
211 $category = array();
212 $category['all'] = __('All', WC_RBP_TXT);
213 $category['active'] = __('Active', WC_RBP_TXT);
214 $category['inactive'] = __('InActive', WC_RBP_TXT);
215 foreach( $this->plugins_data as $data ) {
216 $cat = $data['Category'];
217 foreach( $cat as $id => $c ) {
218 if( ! in_array($c, $category) ) {
219 $category[$id] = $c;
220 }
221 }
222
223 }
224 return $category;
225 }
226
227 public function get_html_addon_category($cats) {
228 $label = __("Search Addons", WC_RBP_TXT);
229 $output = '<div class="wp-filter"> <ul class="filter-links wc_rbp_addons_category addons_category">';
230
231 foreach( $cats as $cat => $catv ) {
232 $output .= '<li id="' . $cat . '" class="' . $cat . ' category"><a href="javascript:void(0);" data-category="' . $cat . '">' . $catv . '</a> | </li>';
233 }
234 $output .= '</ul>';
235
236 $output .= '<div class="addons-search-form">';
237 $output .= '<input type="search" placeholder="' . $label . '" class="wp-filter-search" value="" name="s" />';
238 $output .= '</div>';
239 $output .= '</div>';
240
241 return $output;
242 }
243
244 public function extract_required_plugins($wc_rbp_plugin_data) {
245 $plugins = $wc_rbp_plugin_data['rplugins'];
246 $plugins_return = array();
247 $plugins = explode(',', $plugins);
248 $default_args = array( 'Name' => '', 'URL' => '', 'Version' => '', 'Slug' => '' );
249
250 foreach( $plugins as $plugin ) {
251 if( empty($plugin) ) {
252 continue;
253 }
254 $tmp_arr = array();
255 $plugin = str_replace(array( '[', ']' ), '', $plugin);
256 $plug = explode('|', $plugin);
257
258 foreach( $plug as $p ) {
259
260 $s = preg_split("/ : /", $p);
261 $s[0] = isset($s[0]) ? trim($s[0]) : "";
262 $s[1] = isset($s[1]) ? trim($s[1]) : "";
263 $tmp_arr[$s[0]] = $s[1];
264 }
265
266 if( ! empty($tmp_arr) ) {
267 $tmp_arr = wp_parse_args($tmp_arr, $default_args);
268 $plugins_return[] = $tmp_arr;
269 }
270 }
271 return $plugins_return;
272 }
273
274 public function deactivate_plugin() {
275 $status = $this->addon_actions('deactivate');
276 if( $status === 'invalidcode' ) {
277 wp_send_json_error(array( 'msg' => '<span class="wc_rbp_ajax_error">' . __('Unable to process you request. please try again later', WC_RBP_TXT) . '</span>' ));
278 } else if( $status === 'verifyfailed' ) {
279 wp_send_json_error(array( 'msg' => '<span class="wc_rbp_ajax_ajaxerror">' . __('Unable To De-Activate Addon. Please Try Again Later', WC_RBP_TXT) . '</span>' ));
280 } else if( $status === TRUE ) {
281 wp_send_json_success(array( 'msg' => '<span class="wc_rbp_ajax_success">' . __('Addon De-Activated', WC_RBP_TXT) . '</span>' ));
282 } else if( $status === 'alreadyactive' ) {
283 wp_send_json_success(array( 'msg' => '<span class="wc_rbp_ajax_success">' . __('Addon Already De-Activated', WC_RBP_TXT) . '</span>' ));
284 } else {
285 wp_send_json_error(array( 'msg' => '<span class="wc_rbp_ajax_error">' . __('Unable To De-Activate Addon. Please Try Again Later', WC_RBP_TXT) . '</span>' ));
286 }
287 wp_die();
288 }
289
290 public function addon_actions($action = 'activate') {
291 if( ! isset($_REQUEST['wc_rbp_security_code']) ) {
292 return 'invalidcode';
293 }
294 $nonce_action = 'wc_rbp_' . $action . '_addon';
295 $verify = wp_verify_nonce(sanitize_text_field($_REQUEST['wc_rbp_security_code']), $nonce_action);
296 if( ! $verify ) {
297 return 'verifyfailed';
298 }
299 $function_call = 'wc_rbp_' . $action . '_addon';
300 $status = $function_call(sanitize_text_field($_REQUEST['addon_slug']));
301 if( $status ) {
302 return TRUE;
303 } else if( ! $status ) {
304 return 'alreadyactive';
305 }
306 return FALSE;
307 }
308
309 public function activate_plugin() {
310 $status = $this->addon_actions();
311 if( $status === 'invalidcode' ) {
312 wp_send_json_error(array( 'msg' => '<span class="wc_rbp_ajax_error">' . __('Unable to process you request. please try again later', WC_RBP_TXT) . '</span>' ));
313 } else if( $status === 'verifyfailed' ) {
314 wp_send_json_error(array( 'msg' => '<span class="wc_rbp_ajax_ajaxerror">' . __('Unable To Activate Addon. Please Try Again Later', WC_RBP_TXT) . '</span>' ));
315 } else if( $status === TRUE ) {
316 wp_send_json_success(array( 'msg' => '<span class="wc_rbp_ajax_success">' . __('Addon Activated', WC_RBP_TXT) . '</span>' ));
317 } else if( $status === 'alreadyactive' ) {
318 wp_send_json_success(array( 'msg' => '<span class="wc_rbp_ajax_success">' . __('Addon Already Activated', WC_RBP_TXT) . '</span>' ));
319 } else {
320 wp_send_json_error(array( 'msg' => '<span class="wc_rbp_ajax_error">' . __('Unable To Activate Addon. Please Try Again Later', WC_RBP_TXT) . '</span>' ));
321 }
322 wp_die();
323 }
324
325 public function get_addon_action_button($plugin_slug, $required_plugins) {
326
327 $is_active = wc_rbp_check_active_addon($plugin_slug);
328 $extraClass = '';
329 $activate_button_text = __('Activate', WC_RBP_TXT);
330 $inactivate_button_text = __('Deactivate', WC_RBP_TXT);
331 $requried_satisfied = $this->check_if_requried_satisfied($required_plugins);
332 $activate_button_url = $this->get_addon_action_link($plugin_slug);
333 $inactivate_button_url = $this->get_addon_action_link($plugin_slug, 'deactivate');
334 $activate_button_html = '<button type="button" data-slug="' . $plugin_slug . '" ';
335 $inactivate_button_html = '<button type="button" data-slug="' . $plugin_slug . '" ';
336 $activate_button_html .= 'class="wc-rbp-activate-now button button-primary ';
337 $inactivate_button_html .= 'class="wc-rbp-deactivate-now button button-secondary ';
338
339 if( $is_active ) {
340 $activate_button_html .= ' hidden hide "';
341 $inactivate_button_html .= '"';
342 } else {
343 $activate_button_html .= '"';
344 $inactivate_button_html .= ' hidden hide "';
345
346 }
347
348 if( ! $requried_satisfied ) {
349 $activate_button_html .= ' disabled="disabled" ';
350 }
351
352 $activate_button_html .= ' href="' . $activate_button_url . '" >' . $activate_button_text . '</button>';
353 $inactivate_button_html .= ' href="' . $inactivate_button_url . '" >' . $inactivate_button_text . '</button>';
354 $html_btn = $activate_button_html . $inactivate_button_html;
355 return $html_btn;
356
357 }
358
359 public function check_if_requried_satisfied($requireds) {
360 $success = 0;
361 $failed = 0;
362 foreach( $requireds as $plugin ) {
363 $plugin_status = $this->check_plugin_status($plugin['Slug']);
364 if( $plugin_status === TRUE ) {
365 $success++;
366 } else {
367 $failed++;
368 }
369 }
370
371 if( $success == count($requireds) ) {
372 return TRUE;
373 }
374 return FALSE;
375 }
376
377 public function check_plugin_status($slug) {
378 $val_plugin = validate_plugin($slug);
379 if( is_wp_error($val_plugin) ) {
380 return 'notexist';
381 } else if( is_plugin_active($slug) ) {
382 return TRUE;
383 } else if( is_plugin_inactive($slug) ) {
384 return FALSE;
385 }
386 return FALSE;
387 }
388
389 public function get_addon_action_link($plugin_slug, $type = "active") {
390 $is_active = wc_rbp_check_active_addon($plugin_slug);
391 $action = 'wc_rbp_activate_addon';
392 if( $type == 'deactivate' ) {
393 $action = 'wc_rbp_deactivate_addon';
394 }
395 $url = admin_url('admin-ajax.php?action=' . $action . '&addon_slug=' . $plugin_slug);
396 $url = wp_nonce_url($url, $action, 'wc_rbp_security_code');
397 return $url;
398 }
399
400 public function get_addon_icon($data, $echo = TRUE) {
401 $icon = WC_RBP_IMG . 'addon_icon.jpg';
402
403 if( file_exists($data['addon_root'] . 'icon.png') ) {
404 $icon = $data['addon_url'] . 'icon.png';
405 } else if( file_exists($data['addon_root'] . 'icon.jpg') ) {
406 $icon = $data['addon_url'] . 'icon.jpg';
407 } else if( file_exists($data['addon_root'] . $data['addon_slug'] . '-icon.png') ) {
408 $icon = $data['addon_url'] . $data['addon_slug'] . '-icon.png';
409 } else if( file_exists($data['addon_root'] . $data['addon_slug'] . '-icon.jpg') ) {
410 $icon = $data['addon_url'] . $data['addon_slug'] . '-icon.jpg';
411 } else if( isset($data['icon']) ) {
412 if( filter_var($data['icon'], FILTER_VALIDATE_URL) !== FALSE ) {
413 $icon = $data['icon'];
414 }
415 }
416
417 $icon = '<img src="' . $icon . '" class="plugin-icon" />';
418 if( $echo ) {
419 echo $icon;
420 } else {
421 return $icon;
422 }
423 }
424
425 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Dependency Checker
4 *
5 * Checks if required Dependency plugin is enabled
6 *
7 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
8 * @package Role Based Price For WooCommerce
9 * @subpackage Role Based Price For WooCommerce/FrontEnd
10 * @since 3.0
11 */
12 if( ! defined('WPINC') ) {
13 die;
14 }
15
16 class WooCommerce_Role_Based_Price_Functions {
17
18 /**
19 * Define the core functionality of the plugin.
20 *
21 * Set the plugin name and the plugin version that can be used throughout the plugin.
22 * Load the dependencies, define the locale, and set the hooks for the admin area and
23 * the public-facing side of the site.
24 *
25 * @since 1.0.0
26 */
27 public function __construct() {
28 add_filter('woocommerce_product_object', array( $this, 'setup_product_prices' ));
29 }
30
31
32 public function setup_product_prices($product) {
33 if( $product == NULL ) {
34 return $product;
35 }
36 $product->wc_rbp = wc_rbp_get_product_price($product->ID);
37 $product->wc_rbp_status = wc_rbp_product_status($product->ID);
38
39 do_action_ref_array('wc_rbp_product_class_attribute', array( &$product ));
40 return $product;
41 }
42 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/Admin
8 * @since 3.0
9 */
10 if( ! defined('WPINC') ) {
11 die;
12 }
13
14 class WooCommerce_Role_Based_Price_Product_Pricing {
15 public $already_given_prices = NULL;
16
17 public function __construct($is_hook = TRUE) {
18 $this->already_given_prices = array();
19 if( $is_hook == TRUE ) {
20 add_action('woocommerce_init', array( $this, 'wc_init' ));
21 }
22 }
23
24 public function wc_init() {
25 if( wc_rbp_is_wc_v('>=', '3.0.1') ) {
26 add_filter('woocommerce_product_get_regular_price', array( &$this, 'get_regular_price' ), 99, 2);
27 add_filter('woocommerce_product_get_sale_price', array( &$this, 'get_selling_price' ), 99, 2);
28 add_filter('woocommerce_product_get_price', array( &$this, 'get_price' ), 99, 2);
29 add_filter('woocommerce_product_variation_get_regular_price', array( &$this, 'get_regular_price' ), 99, 2);
30 add_filter('woocommerce_product_variation_get_sale_price', array( &$this, 'get_selling_price' ), 99, 2);
31 add_filter('woocommerce_product_variation_get_price', array( &$this, 'get_price' ), 99, 2);
32 } else {
33 add_filter('woocommerce_get_regular_price', array( &$this, 'get_regular_price' ), 99, 2);
34 add_filter('woocommerce_get_sale_price', array( &$this, 'get_selling_price' ), 99, 2);
35 add_filter('woocommerce_get_price', array( &$this, 'get_price' ), 99, 2);
36 }
37
38 add_filter('woocommerce_get_variation_regular_price', array( &$this, 'get_variation_regular_price' ), 99, 4);
39 add_filter('woocommerce_get_variation_price', array( &$this, 'get_variation_price' ), 99, 4);
40 add_filter('woocommerce_get_price_html', array( &$this, 'get_price_html' ), 99, 2);
41 }
42
43 /**
44 * @param $price
45 * @param $product
46 *
47 * @return mixed|string
48 */
49 public function get_selling_price($price, $product) {
50 $price = $this->get_product_price($price, $product, 'selling_price');
51 $price = apply_filters("wc_rbp_product_selling_price", $price, $product, $this);
52 return $price;
53 }
54
55 public function get_product_price($base_price, $product, $price_meta_key = 'regular_price', $current_user = '') {
56 if( ! apply_filters('role_based_price_status', TRUE) ) {
57 return $base_price;
58 }
59 $wc_rbp_price = FALSE;
60
61 $opposite_key = 'selling_price';
62 if( $price_meta_key == 'selling_price' ) {
63 $opposite_key = 'regular_price';
64 }
65 $product_id = $this->check_product_get_id($product);
66
67 if( empty($current_user) ) {
68 $current_user = wc_rbp_get_current_user();
69 }
70
71
72 $product_type = wp_get_post_terms($product_id, 'product_type', array( 'fields' => 'names' ));
73 if( in_array('variable', $product_type) ) {
74 return $base_price;
75 }
76 $key = md5($base_price . '-' . $product_id . '-' . $price_meta_key . '-' . $opposite_key . '-' . $current_user);
77
78
79 if( isset($this->already_given_prices[$key]) ) {
80 $wc_rbp_price = $this->already_given_prices[$key];
81 } else {
82 $wc_rbp_status = product_rbp_status($product_id);
83 $allowed_roles = wc_rbp_allowed_roles();
84
85 if( in_array($current_user, $allowed_roles) ) {
86 $rbp_price = wc_rbp_price($product_id, $current_user, 'all', array());
87
88 if( $wc_rbp_status ) {
89 if( $rbp_price === FALSE ) {
90 $wc_rbp_price = $base_price;
91 } else {
92 if( $price_meta_key == 'all' ) {
93 $wc_rbp_price = $rbp_price[$price_meta_key];
94 }
95
96 if( isset($rbp_price[$price_meta_key]) && isset($rbp_price[$opposite_key]) ) {
97 if( $rbp_price[$price_meta_key] === "" && $rbp_price[$opposite_key] === "" ) {
98 $wc_rbp_price = $base_price;
99 }
100 if( ( $rbp_price[$price_meta_key] === 0 || $rbp_price[$price_meta_key] === '0' ) || ( $rbp_price[$opposite_key] === 0 || $rbp_price[$opposite_key] === '0' ) ) {
101 $wc_rbp_price = 0;
102 } else if( $rbp_price[$price_meta_key] === "" && $rbp_price[$opposite_key] !== "" ) {
103 $wc_rbp_price = $rbp_price[$opposite_key];
104 } else if( $rbp_price[$price_meta_key] !== "" && $rbp_price[$opposite_key] === "" ) {
105 $wc_rbp_price = $rbp_price[$price_meta_key];
106 } else if( $rbp_price[$price_meta_key] !== "" ) {
107 $wc_rbp_price = $rbp_price[$price_meta_key];
108 }
109 } else if( isset($rbp_price[$price_meta_key]) && ! isset($rbp_price[$opposite_key]) ) {
110 if( $rbp_price[$price_meta_key] === "" ) {
111 $wc_rbp_price = $base_price;
112 } else if( $rbp_price[$price_meta_key] === "0" || $rbp_price[$price_meta_key] === 0 ) {
113 $wc_rbp_price = 0;
114 } else if( $rbp_price[$price_meta_key] !== "" ) {
115 $wc_rbp_price = $rbp_price[$price_meta_key];
116 }
117 } else if( isset($rbp_price[$opposite_key]) && ! isset($rbp_price[$price_meta_key]) ) {
118 if( $rbp_price[$opposite_key] === "" ) {
119 $wc_rbp_price = $base_price;
120 }
121 if( $rbp_price[$opposite_key] === "0" || $rbp_price[$opposite_key] === 0 ) {
122 $wc_rbp_price = 0;
123 } else if( $rbp_price[$opposite_key] !== "" ) {
124 $wc_rbp_price = $rbp_price[$opposite_key];
125 }
126 }
127 }
128
129 } else {
130 $wc_rbp_price = $base_price;
131 }
132 } else {
133 $wc_rbp_price = $base_price;
134 }
135 }
136
137 //$return = apply_filters('wc_rbp_product_price_value',$return,$price,$product_id,$product,$price_meta_key,$current_user);
138 $wc_rbp_price = apply_filters('wc_rbp_product_price_value', $wc_rbp_price, $base_price, $product_id, $product, $price_meta_key, $current_user);
139
140 if( $wc_rbp_price !== '' ) {
141 $this->already_given_prices[$key] = $wc_rbp_price;
142 }
143
144
145 $return = wc_format_decimal($wc_rbp_price);
146
147 $wpml_integration_status = wc_rbp_option('enable_wpml_integration');
148
149 if( $wpml_integration_status == 'on' ) {
150 if( class_exists('woocommerce_wpml') ) {
151 $return = apply_filters('wcml_raw_price_amount', $return);
152 }
153 }
154
155 return $return;
156 }
157
158 public function check_product_get_id($product) {
159 $product_id = 0;
160
161 if( wc_rbp_is_wc_v('>=', '3.0.1') ) {
162
163 if( is_numeric($product) ) {
164 return $product;
165 } else if( $this->is_simple_product($product) ) {
166 $product_id = $product->get_id();
167 } else if( $this->is_variable_product($product) ) {
168 $product_id = $product->get_id();
169 } else if( $this->is_variation_product($product) ) {
170 $product_id = $product->get_id();
171 }
172
173 /**
174 * $product_id needs to be set also if conditions above are not true.
175 */
176 $product_id = $product->get_id();
177
178 } else {
179
180 if( is_numeric($product) ) {
181 return $product;
182 } else if( $this->is_simple_product($product) ) {
183 $product_id = $product->id;
184 } else if( $this->is_variable_product($product) ) {
185 $product_id = $product->id;
186 } else if( $this->is_variation_product($product) ) {
187 $product_id = $product->variation_id;
188 }
189 }
190
191
192 return $product_id;
193 }
194
195 private function is_simple_product($product) {
196 $class = $this->get_product_class($product);
197 $classes = apply_filters("wc_rbp_simple_product_class", array( 'WC_Product_Simple', 'WC_Product_Yith_Bundle' ));
198 if( in_array($class, $classes) ) {
199 return TRUE;
200 }
201 return FALSE;
202 }
203
204 private function get_product_class($product) {
205 $class = get_class($product);
206 $class = str_replace('_RBP', '', $class);
207 return $class;
208 }
209
210 private function is_variable_product($product) {
211 $class = $this->get_product_class($product);
212 if( $class == 'WC_Product_Variable' ) {
213 return TRUE;
214 }
215 return FALSE;
216 }
217
218 private function is_variation_product($product) {
219 $class = $this->get_product_class($product);
220 if( $class == 'WC_Product_Variation' ) {
221 return TRUE;
222 }
223 return FALSE;
224 }
225
226 /**
227 * Returns the product's active price.
228 *
229 * @param string $price
230 * @param string $product
231 *
232 * @return string price
233 */
234 public function get_price($price = '', $product = '') {
235 if( empty($product) ) {
236 return $price;
237 }
238 $sale_price = $product->get_sale_price();
239 $wcrbp_price = ( $sale_price !== '' && $sale_price > 0 ) ? $sale_price : $this->get_regular_price($price, $product);
240 $wcrbp_price = wc_format_decimal($wcrbp_price);
241 $wcrbp_price = apply_filters("wc_rbp_product_get_price", $wcrbp_price, $product, $this);
242 return $wcrbp_price;
243 }
244
245 /**
246 * Returns the product's regular price
247 *
248 * @param $price
249 * @param $product
250 *
251 * @return string price
252 */
253 public function get_regular_price($price, $product) {
254 $price = $this->get_product_price($price, $product);
255 $price = apply_filters("wc_rbp_product_regular_price", $price, $product, $this);
256 return $price;
257 }
258
259 /**
260 * Get the min or max variation active price.
261 *
262 * @param $price
263 * @param $product
264 * @param string $min_or_max - min or max
265 * @param boolean $display Whether the value is going to be displayed
266 *
267 * @return string price
268 */
269 public function get_variation_price($price, $product, $min_or_max, $display) {
270 return $this->get_variation_regular_price($price, $product, $min_or_max, $display, 'selling_price');
271 }
272
273 /**
274 * Get the min or max variation regular price.
275 *
276 * @param string $min_or_max - min or max
277 * @param boolean $display Whether the value is going to be displayed
278 *
279 * @return string price
280 */
281 public function get_variation_regular_price($price, $product, $min_or_max, $display, $price_meta_key = 'regular_price') {
282 $return = $price;
283 $display = array();
284 $pid = 0;
285
286 if( wc_rbp_is_wc_v('>=', '3.0') ) {
287 $pid = $product->get_id();
288 } else {
289 $pid = $product->id;
290 }
291
292 $role = wc_rbp_get_current_user();
293 $opp_key = wc_rbp_get_oppo_metakey($price_meta_key);
294 $prices = wc_rbp_get_variation_data($pid, $role);
295
296
297 foreach( $prices as $id => $arr ) {
298 if( ! is_array($arr) ) {
299 continue;
300 }
301 }
302
303 if( empty($prices[$price_meta_key]) && empty($prices[$opp_key]) ) {
304 if( empty($prices['base_' . $price_meta_key]) && ! empty($prices['base_' . $opp_key]) ) {
305 $prices = $prices['base_' . $opp_key];
306 } else {
307 $prices = $prices['base_' . $price_meta_key];
308 }
309 } else if( empty($prices[$price_meta_key]) && ! empty($prices[$opp_key]) ) {
310 $prices = $prices[$opp_key];
311 } else {
312 $prices = $prices[$price_meta_key];
313 }
314
315
316 if( $min_or_max == 'min' ) {
317 asort($prices);
318 } else {
319 arsort($prices);
320 }
321
322 if( $display ) {
323 $variation_id = key($prices);
324 $return = $display[$variation_id];
325 } else {
326 $return = current($prices);
327 }
328
329 return $return;
330 }
331
332 public function get_price_html($price = '', $product) {
333 if( 'WC_Product_Variable' == get_class($product) ) {
334 $product_id = $this->check_product_get_id($product);
335 $wc_rbp_status = $this->product_rbp_status($product_id, $product);
336 if( ! $wc_rbp_status ) {
337 return $price;
338 }
339
340 if( wc_rbp_is_wc_v('>=', '3.0') ) {
341 return $this->get_price_html_wc3($price, $product);
342 } else {
343 return $this->get_price_html_below_wc3($price, $product);
344 }
345 }
346
347 return $price;
348 }
349
350 public function product_rbp_status($id, $product) {
351 $type = $product->get_type();
352 if( $type == 'variable' ) {
353 $variations = $product->get_children();
354
355 if( is_array($variations) ) {
356 foreach( $variations as $i ) {
357 $status = product_rbp_status($i);
358 if( $status ) {
359 return TRUE;
360 }
361 }
362 }
363 } else {
364 $status = product_rbp_status($id);
365 if( $status ) {
366 return TRUE;
367 }
368 }
369
370 return FALSE;
371 }
372
373 public function get_price_html_wc3($price = '', $product) {
374
375 $prices = $product->get_variation_prices(TRUE);
376
377 if( empty($prices['price']) ) {
378 return apply_filters('woocommerce_variable_empty_price_html', '', $this);
379 }
380
381 $prices = array();
382 $prices['min_price'] = $product->get_variation_price('min', FALSE);
383 $prices['max_price'] = $product->get_variation_price('max', FALSE);
384 $prices['min_reg_price'] = $product->get_variation_regular_price('min', TRUE);
385 $prices['max_reg_price'] = $product->get_variation_regular_price('max', TRUE);
386 $prices = $this->get_variation_tax_status_price($prices, $product);
387
388 /*if( $prices['min_price'] !== $prices['max_price'] ) {
389 $price = apply_filters('woocommerce_variable_price_html', wc_format_price_range($prices['min_price'], $prices['max_price']) . $product->get_price_suffix(), $product);
390 } else if( $product->is_on_sale() && $prices['min_reg_price'] === $prices['max_reg_price'] ) {
391 $price = apply_filters('woocommerce_variable_price_html', wc_format_sale_price(wc_price($prices['max_reg_price']), wc_price($prices['min_price'])) . $product->get_price_suffix(), $product);
392 } else {
393 $price = apply_filters('woocommerce_variable_price_html', wc_price($prices['min_price']) . $product->get_price_suffix(), $product);
394 }*/
395
396 if( $prices['min_price'] !== $prices['max_price'] ) {
397 $price = wc_format_price_range($prices['min_price'], $prices['max_price']);
398 } else if( $product->is_on_sale() && $prices['min_reg_price'] === $prices['max_reg_price'] ) {
399 $price = wc_format_sale_price(wc_price($prices['max_reg_price']), wc_price($prices['min_price']));
400 } else {
401 $price = wc_price($prices['min_price']);
402 }
403
404 return $price;
405
406 }
407
408 public function get_variation_tax_status_price($prices, $product) {
409 if( 'incl' === get_option('woocommerce_tax_display_shop') ) {
410 if( wc_rbp_is_wc_v('>=', '3.0') ) {
411 $prices['min_price'] = '' === $prices['min_price'] ? '' : wc_get_price_including_tax($product, array(
412 'qty' => 1,
413 'price' => $prices['min_price'],
414 ));
415 $prices['max_price'] = '' === $prices['max_price'] ? '' : wc_get_price_including_tax($product, array(
416 'qty' => 1,
417 'price' => $prices['max_price'],
418 ));
419
420 $prices['min_reg_price'] = '' === $prices['min_reg_price'] ? '' : wc_get_price_including_tax($product, array(
421 'qty' => 1,
422 'price' => $prices['min_reg_price'],
423 ));
424 $prices['max_reg_price'] = '' === $prices['max_reg_price'] ? '' : wc_get_price_including_tax($product, array(
425 'qty' => 1,
426 'price' => $prices['max_reg_price'],
427 ));
428
429 } else {
430 $prices[0] = '' === $prices[0] ? '' : $product->get_price_including_tax(1, $prices[0]);
431 $prices[1] = '' === $prices[1] ? '' : $product->get_price_including_tax(1, $prices[1]);
432 }
433
434 } else {
435 if( wc_rbp_is_wc_v('>=', '3.0') ) {
436
437 $prices['min_price'] = '' === $prices['min_price'] ? '' : wc_get_price_excluding_tax($product, array(
438 'qty' => 1,
439 'price' => $prices['min_price'],
440 ));
441 $prices['max_price'] = '' === $prices['max_price'] ? '' : wc_get_price_excluding_tax($product, array(
442 'qty' => 1,
443 'price' => $prices['max_price'],
444 ));
445
446 $prices['min_reg_price'] = '' === $prices['min_reg_price'] ? '' : wc_get_price_excluding_tax($product, array(
447 'qty' => 1,
448 'price' => $prices['min_reg_price'],
449 ));
450 $prices['max_reg_price'] = '' === $prices['max_reg_price'] ? '' : wc_get_price_excluding_tax($product, array(
451 'qty' => 1,
452 'price' => $prices['max_reg_price'],
453 ));
454
455 } else {
456 $prices[0] = '' === $prices[0] ? '' : $product->get_price_including_tax(1, $prices[0]);
457 $prices[1] = '' === $prices[1] ? '' : $product->get_price_including_tax(1, $prices[1]);
458 }
459 }
460
461 return $prices;
462 }
463
464 /**
465 * Returns the price in html format.
466 *
467 * @access public
468 *
469 * @param string $price (default: '')
470 *
471 * @return string
472 */
473 public function get_price_html_below_wc3($price = '', $product) {
474
475 // Ensure variation prices are synced with variations
476 if( $product->get_variation_regular_price('min') === FALSE || $product->get_variation_price('min') === FALSE || $product->get_variation_price('min') === '' || $product->get_price() === '' ) {
477 $product->variable_product_sync($product->get_id());
478 }
479 // Get the price
480 if( $product->get_price() === '' ) {
481 $price = apply_filters('woocommerce_variable_empty_price_html', '', $product);
482 } else {
483
484 // Main price
485 $prices = array( $product->get_variation_price('min', FALSE), $product->get_variation_price('max', FALSE) );
486
487 $prices = $this->get_variation_tax_status_price($prices, $product);
488
489 $price = $prices[0] !== $prices[1] ? sprintf(_x(' % 1$s & ndash;%2$s', 'Price range: from - to', 'woocommerce'), wc_price($prices[0]), wc_price($prices[1])) : wc_price($prices[0]);
490 // Sale
491 $prices = array(
492 $product->get_variation_regular_price('min', TRUE),
493 $product->get_variation_regular_price('max', TRUE),
494 );
495 sort($prices);
496
497 $prices = $this->get_variation_tax_status_price($prices, $product);
498
499 $saleprice = $prices[0] !== $prices[1] ? sprintf(_x(' % 1$s & ndash;%2$s', 'Price range: from - to', 'woocommerce'), wc_price($prices[0]), wc_price($prices[1])) : wc_price($prices[0]);
500
501
502 if( $prices[0] == 0 && $prices[1] == 0 ) {
503 $price = __('Free! ', 'woocommerce');
504 $price = apply_filters('woocommerce_variable_free_price_html', $price, $product);
505 } else if( $price !== $saleprice ) {
506 if( wc_rbp_is_wc_v(' >= ', '3.0') ) {
507 $price = apply_filters('woocommerce_variable_sale_price_html', wc_format_price_range($saleprice, $price) . $product->get_price_suffix(), $product);
508 } else {
509 $price = apply_filters('woocommerce_variable_sale_price_html', $product->get_price_html_from_to($saleprice, $price) . $product->get_price_suffix(), $product);
510 }
511 } else {
512 $price = apply_filters('woocommerce_variable_price_html', $price . $product->get_price_suffix(), $product);
513 }
514 }
515
516 return $price;
517 }
518 }
1 <?php
2 /**
3 * Simple Product Role Based Price Settings
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @since 1.0
7 * @package WooCommerce_Role_Based_Price
8 * @subpackage WooCommerce_Role_Based_Price/admin
9 * @author Varun Sridharan <varunsridharan23@gmail.com>
10 */
11 if( ! defined('WPINC') ) {
12 exit;
13 }
14
15 class WooCommerce_Role_Based_Price_Shortcode_Handler {
16
17 private static $_instance = NULL;
18 private static $db_prices = NULL;
19
20 public function __construct() {
21 add_shortcode('wc_rbp', array( $this, 'shortcodehandler' ));
22 }
23
24 function is_aeliacs_active() {
25 return isset($GLOBALS['woocommerce-aelia-currencyswitcher']) && is_object($GLOBALS['woocommerce-aelia-currencyswitcher']);
26 }
27
28 public function shortcodehandler($attrs) {
29 $vars = shortcode_atts(array(
30 'id' => NULL,
31 'price' => 'regular_price',
32 'role' => 'current',
33 ), $attrs, 'wc_rbp');
34
35 if( $vars['id'] == NULL ) {
36 global $product;
37
38
39 $id = '';
40 if( wc_rbp_is_wc_v('>=', '3.0.1') ) {
41 $id = $product->get_id();
42 } else {
43 $product->id;
44 }
45
46 if( ! isset($id) ) {
47 return __('Invalid Product ID Given', WC_RBP_TXT);
48 }
49 $vars['id'] = $id;
50 }
51
52 if( $vars['role'] == NULL ) {
53 return __('Invalid User Role Given', WC_RBP_TXT);
54 }
55
56 if( $vars['price'] == 'product_regular_price' || $vars['price'] == 'product_selling_price' ) {
57 return self::get_base_product_price($vars['id'], $vars['price']);
58 }
59
60 if( $vars['price'] != 'regular_price' && $vars['price'] != 'selling_price' ) {
61 return __('Invalid Price Type Given', WC_RBP_TXT);
62 }
63
64 $product_status = product_rbp_status($vars['id']);
65 $this->rbpPP = '';
66 if( $product_status ) {
67 $this->rbpPP = new WooCommerce_Role_Based_Price_Product_Pricing;
68
69 if( $vars['role'] == 'current' ) {
70 $vars['role'] = wc_rbp_get_current_user();
71 }
72
73 return self::get_selprice($vars['role'], $vars['price'], $vars['id']);
74 }
75 return '';
76 }
77
78
79 public function get_base_product_price($id, $price) {
80 if( ! defined('WC_RBP_SHORTCODE_PRODUCT_BASE_PRICING') ) {
81 define('WC_RBP_SHORTCODE_PRODUCT_BASE_PRICING', TRUE);
82 }
83
84 $product = new WC_Product($id);
85 if( $price == 'product_regular_price' ) {
86 return $product->get_regular_price();
87 }
88 if( $price == 'product_selling_price' ) {
89 return $product->get_sale_price();
90 }
91 }
92
93 public function get_selprice($role, $price = 'all', $product_id) {
94 $product = wc_get_product($product_id);
95 $p = $this->rbpPP->get_product_price('', $product, $price, $role);
96 return wc_price($p);
97 }
98 }
...\ No newline at end of file ...\ No newline at end of file
1 table.wc_rbp_settings_table {
2 box-shadow : none;
3 border : 0 none;
4 border-spacing : 0;
5 clear : both;
6 margin : 0;
7 max-width : 900px;
8 min-width : 800px;
9 width : auto;
10 background : #fff;
11 border : 1px solid #e1e1e1;
12 }
13
14 table.wc_rbp_settings_table th {
15 font-weight : bold;
16 text-align : left;
17 font-size : 14px;
18 padding : 8px 15px;
19 line-height : 28px;
20 border-bottom : 1px solid #e1e1e1;
21 }
22
23 table.wc_rbp_settings_table td {
24 padding : 13px 15px;
25 border-top : 1px solid #f5f5f5;
26 width : 70% !important;
27 }
28
29 table.wc_rbp_settings_table td:first-child {
30 width : 26%;
31 }
32
33 table.wc_rbp_settings_table td.wcff-sortable {
34 cursor : move;
35 }
36
37 table.wc_rbp_settings_table td.add {
38 width : 40px;
39 }
40
41 table.wc_rbp_settings_table td.remove {
42 width : 20px;
43 }
44
45 table.wc_rbp_settings_table tr > th {
46 width : 30% !important;
47 vertical-align : middle;
48 background : #F9F9F9;
49 border-top : 1px solid #f0f0f0;
50 border-right : 1px solid #E1E1E1;
51 }
52
53 table.wc_rbp_settings_table > tbody > tr:first-child > td,
54 table.wc_rbp_settings_table > tbody > tr:first-child > th {
55 border-top : 0 none;
56 }
57
58 table.wc_rbp_settings_table tr > th label {
59 display : block;
60 font-size : 13px;
61 line-height : 1.4em;
62 font-weight : bold;
63 padding : 0;
64 margin : 0 0 3px;
65 color : #333;
66 }
67
68 table.wc_rbp_settings_table tr > th p {
69 display : block;
70 line-height : 1.4em;
71 padding : 0 !important;
72 margin : 3px 0 0 !important;
73 font-size : 12px;
74 font-style : italic;
75 /*line-height: 16px;*/
76 color : #666;
77 }
78
79 table.wc_rbp_settings_table select,
80 table.wc_rbp_settings_table textarea,
81 table.wc_rbp_settings_table input[type=text],
82 table.wc_rbp_settings_table input[type=password],
83 table.wc_rbp_settings_table input[type=email],
84 table.wc_rbp_settings_table input[type=number] {
85 width : 100%;
86 padding : 3px;
87 height : auto;
88 }
89
90 table.wc_rbp_settings_table textarea {
91 resize : vertical;
92 }
93
94 .wc_rbp_settings .wc_rbp_settings_submenu {
95 display : block !important;
96 margin : 10px 0 0 !important;
97 width : 100%;
98 }
99
100 .wc_rbp_settings .addon-screenshots ul {
101 padding : 0;
102 }
103
104 .wc_rbp_settings .addon-screenshots ul li {
105 display : inline-block;
106 margin-right : 10px;
107 padding : 0;
108 }
109
110 .wc_rbp_settings .addon-screenshots ul li a {
111 border : 1px solid #ccc;
112 padding : 2px 8px;
113 }
114
115 .wc_rbp_settings .addon-screenshots ul li a:hover {
116 background : #444;
117 color : white;
118 }
119
120 .wc_rbp_settings .addons-search-form {
121 display : inline-block;
122 float : right;
123 padding : 5px 0;
124 right : 0;
125 }
126
127 .wc_rbp_settings .addons-search-form .wp-filter-search {
128 line-height : 20px;
129 margin : 4px 0;
130 padding : 6px 5px;
131 }
132
133 .wc_rbp_addon_listing .plugin-icon {
134 border : 1px solid #ccc;
135 border-radius : 5px;
136 }
137
138 div.wc-rbp-enhanced-select {
139 display : inline-block;
140 margin-right : 10px !important;
141 vertical-align : middle;
142 min-width : 200px;
143 width : 100% !important;
144 }
145
146 div.wc-rbp-enhanced-select div.selectize-dropdown {
147 width : 100% !important;
148 }
149
150 .wc_rbp_base_product_price {
151 display : inline-block;
152 margin-right : 25px;
153 margin-top : 5px;
154 font-style : italic;
155 font-weight : bold;
156 }
157
158 .wc_rbp_base_product_price .headTxt {
159 color : red !important;
160 font-style : normal !important;
161 font-weight : normal !important;
162 }
163
164 /***@todo : check it */
165
166 div.jqibox {
167 z-index : 100010 !important;
168 }
169
170 /***@todo : check it */
171
172 div.jqifade {
173 background-color : black !important;
174 }
175
176 .enable_text {
177 color : black;
178 font-size : 14px;
179 font-weight : bold;
180 margin-right : 10px;
181 }
182
183 .wc_rbp_settings_content {
184 display : inline-block;
185 float : none;
186 margin-top : 10px;
187 width : 100%;
188 }
189
190 .subsubsub.addons_category {
191 display : block;
192 font-size : 14px;
193 margin : 10px 0;
194 width : 100%;
195 }
196
197 #wc-rbp-product-editor .selectize-control {
198 display : inline-block !important;
199 margin-left : 10px !important;
200 vertical-align : middle !important;
201 }
202
203 #wc-rbp-product-editor .selectize-control > .selectize-input {
204 padding : 5px 10px !important;
205 }
206
207 #wc-rbp-product-editor .selectize-dropdown.single {
208 font-weight : normal !important;
209 }
210
211 .wc_rbp_price_editor_footer {
212 border-top : 1px solid #ccc;
213 margin-top : 20px;
214 padding-top : 20px !important;
215 }
216
217 .wc_rbp_price_editor_footer > p {
218 margin : 0 !important;
219 }
220
221 .wc_rbp_price_editor_footer #update_price {
222 float : right;
223 }
224
225 .wc_rbp_ajax_overlay {
226 background : black none repeat scroll 0 0;
227 opacity : 0.3;
228 position : fixed;
229 z-index : 2147483647;
230 display : none;
231 }
232
233 .wc_rbp_ajax_overlay .sk-folding-cube {
234 height : 75px;
235 margin : 0 auto;
236 top : 50%;
237 width : 75px;
238 }
239
240 /**
241 * WC RBP Price Editor Tab Styles
242 */
243
244 .wc_rbp_popup_section {
245 border-bottom : 1px solid #ccc;
246 margin-bottom : 10px;
247 padding-bottom : 10px;
248 }
249
250 .wc_rbp_popup_section:last-child {
251 border-bottom : 0px solid #ccc;
252 margin-bottom : 10px;
253 padding-bottom : 10px;
254 }
255
256 div.wc_rbp_popup_section > div.wc_rbp_pop_field {
257 display : inline-block;
258 margin-right : 7px;
259 margin-left : 0;
260 width : 99%;
261 }
262
263 div.wc_rbp_popup_section div.wc_rbp_pop_field_50 {
264 display : inline-block;
265 margin-right : calc(50% - 49%);
266 margin-left : 0;
267 width : 49%;
268 }
269
270 div.wc_rbp_popup_section div.wc_rbp_pop_field_50:last-child {
271 display : inline-block;
272 margin-right : 0;
273 margin-left : calc(50% - 49%);
274 }
275
276 .wc_rbp_addon_listing .plugin-card-top.wc-rbp-addons-required-plugins {
277 min-height : auto;
278 padding : 5px 20px;
279 }
280
281 .wc_rbp_addon_listing .plugin-card-top.wc-rbp-addons-required-plugins > div > p {
282 margin : 0;
283 }
284
285 .wc_rbp_addon_listing .plugin-card-top.wc-rbp-addons-required-plugins ul {
286 list-style : inside none disc;
287 display : inline-block;
288 margin-bottom : 10px;
289 margin-top : 10px;
290 }
291
292 .wc_rbp_required_addon_plugin_name {
293 color : #0073aa;
294 }
295
296 .wc_rbp_required_addon_plugin_status.active {
297 color : green;
298 font-weight : bold;
299 }
300
301 .wc_rbp_required_addon_plugin_status.deactivated {
302 color : red;
303 font-weight : bold;
304 }
305
306 .wc-rbp-addons-required-plugins li {
307 padding : 0 10px;
308 }
309
310 .wc-rbp-addons-required-plugins li.notexist {
311 background : #ffe1e1 none repeat scroll 0 0;
312 border : 1px solid red;
313 font-weight : bold;
314 }
315
316 .wc-rbp-addons-required-plugins li.notexist .wc_rbp_required_addon_plugin_name {
317 color : white;
318 }
319
320 .wc_rbp_addon_listing .plugin-card-top.wc-rbp-addons-required-plugins h3 {
321 color : navy;
322 font-size : 14px;
323 margin-bottom : 0;
324 }
325
326 .wc_rbp_addon_listing .desc.column-description {
327 margin-right : 0;
328 }
329
330 .wc_rbp_addon_listing .name.column-name {
331 margin-right : 0;
332 }
333
334 .wc_rbp_addon_listing .plugin-card-bottom .column-updated {
335 width : calc(100% - 300px);
336 }
337
338 .wc_rbp_addon_listing .wc_rbp_ajax_overlay {
339 border-radius : 3px;
340 opacity : 0.13;
341 position : absolute;
342 }
343
344 .wc_rbp_addon_listing .sk-folding-cube {
345 height : 50px;
346 margin : 10px auto;
347 top : 30%;
348 width : 50px;
349 }
350
351 .column-downloaded.wc_rbp_ajax_response {
352 float : none;
353 max-width : none;
354 display : block;
355 max-width : 330px;
356 }
357
358 .column-downloaded.wc_rbp_ajax_response span {
359 margin-top : 0;
360 }
361
362 .wc_rbp_ajax_error {
363 color : red;
364 display : block;
365 font-size : 13px;
366 font-weight : bold;
367 margin-top : 5px;
368 }
369
370 .wc_rbp_ajax_success {
371 color : green;
372 display : block;
373 font-size : 13px;
374 font-weight : bold;
375 margin-top : 5px;
376 }
377
378 .sk-folding-cube {
379 margin : 20px auto;
380 width : 40px;
381 height : 40px;
382 position : relative;
383 -webkit-transform : rotateZ(45deg);
384 transform : rotateZ(45deg);
385 }
386
387 .sk-folding-cube .sk-cube {
388 float : left;
389 width : 50%;
390 height : 50%;
391 position : relative;
392 -webkit-transform : scale(1.1);
393 -ms-transform : scale(1.1);
394 transform : scale(1.1);
395 }
396
397 .sk-folding-cube .sk-cube:before {
398 content : '';
399 position : absolute;
400 top : 0;
401 left : 0;
402 width : 100%;
403 height : 100%;
404 background-color : #FFF;
405 -webkit-animation : sk-foldCubeAngle 2.4s infinite linear both;
406 animation : sk-foldCubeAngle 2.4s infinite linear both;
407 -webkit-transform-origin : 100% 100%;
408 -ms-transform-origin : 100% 100%;
409 transform-origin : 100% 100%;
410 }
411
412 .sk-folding-cube .sk-cube2 {
413 -webkit-transform : scale(1.1) rotateZ(90deg);
414 transform : scale(1.1) rotateZ(90deg);
415 }
416
417 .sk-folding-cube .sk-cube3 {
418 -webkit-transform : scale(1.1) rotateZ(180deg);
419 transform : scale(1.1) rotateZ(180deg);
420 }
421
422 .sk-folding-cube .sk-cube4 {
423 -webkit-transform : scale(1.1) rotateZ(270deg);
424 transform : scale(1.1) rotateZ(270deg);
425 }
426
427 .sk-folding-cube .sk-cube2:before {
428 -webkit-animation-delay : 0.3s;
429 animation-delay : 0.3s;
430 }
431
432 .sk-folding-cube .sk-cube3:before {
433 -webkit-animation-delay : 0.6s;
434 animation-delay : 0.6s;
435 }
436
437 .sk-folding-cube .sk-cube4:before {
438 -webkit-animation-delay : 0.9s;
439 animation-delay : 0.9s;
440 }
441
442 @-webkit-keyframes sk-foldCubeAngle {
443 0%,
444 10% {
445 -webkit-transform : perspective(140px) rotateX(-180deg);
446 transform : perspective(140px) rotateX(-180deg);
447 opacity : 0;
448 }
449 25%,
450 75% {
451 -webkit-transform : perspective(140px) rotateX(0deg);
452 transform : perspective(140px) rotateX(0deg);
453 opacity : 1;
454 }
455 90%,
456 100% {
457 -webkit-transform : perspective(140px) rotateY(180deg);
458 transform : perspective(140px) rotateY(180deg);
459 opacity : 0;
460 }
461 }
462
463 @keyframes sk-foldCubeAngle {
464 0%,
465 10% {
466 -webkit-transform : perspective(140px) rotateX(-180deg);
467 transform : perspective(140px) rotateX(-180deg);
468 opacity : 0;
469 }
470 25%,
471 75% {
472 -webkit-transform : perspective(140px) rotateX(0deg);
473 transform : perspective(140px) rotateX(0deg);
474 opacity : 1;
475 }
476 90%,
477 100% {
478 -webkit-transform : perspective(140px) rotateY(180deg);
479 transform : perspective(140px) rotateY(180deg);
480 opacity : 0;
481 }
482 }
483
484 .bar {
485 width : auto;
486 min-width : 100px;
487 max-width : 600px;
488 height : 20px;
489 border : 1px solid #2980b9;
490 border-radius : 3px;
491 background-image : repeating-linear-gradient(-45deg, #2980b9, #2980b9 11px, #eee 10px, #eee 20px /* determines size */
492 );
493 background-size : 28px 28px;
494 animation : move .5s linear infinite;
495 }
496
497 @keyframes move {
498 0% {
499 background-position : 0 0;
500 }
501 100% {
502 background-position : 28px 0;
503 }
504 }
505
506 /**
507 * Styled Checkbox CSS Code
508 */
509
510 .switchery {
511 background-color : #fff;
512 border : 1px solid #dfdfdf;
513 border-radius : 20px;
514 cursor : pointer;
515 display : inline-block;
516 height : 30px;
517 position : relative;
518 vertical-align : middle;
519 width : 50px;
520 -moz-user-select : none;
521 -khtml-user-select : none;
522 -webkit-user-select : none;
523 -ms-user-select : none;
524 user-select : none;
525 box-sizing : content-box;
526 background-clip : content-box
527 }
528
529 .switchery > small {
530 background : #fff;
531 border-radius : 100%;
532 box-shadow : 0 1px 3px rgba(0, 0, 0, 0.4);
533 height : 30px;
534 position : absolute;
535 top : 0;
536 width : 30px
537 }
538
539 .switchery-small {
540 border-radius : 20px;
541 height : 20px;
542 width : 33px
543 }
544
545 .switchery-small > small {
546 height : 20px;
547 width : 20px
548 }
549
550 .switchery-large {
551 border-radius : 40px;
552 height : 40px;
553 width : 66px
554 }
555
556 .switchery-large > small {
557 height : 40px;
558 width : 40px
559 }
560
561 .wcrbp-tab-nav {
562 margin-bottom : -1px;
563 }
564
565 .wcrbp-tab-nav > li {
566 margin : 0;
567 display : inline-block;
568 }
569
570 .wcrbp-tab-nav > .wcrbp-tab-active {
571 border : 1px solid #dfdfdf;
572 border-bottom-color : transparent;
573 background : #fdfdfd;
574 }
575
576 .wcrbp-tab-nav > li > a {
577 display : block;
578 padding : 3px 5px 5px;
579 text-decoration : none;
580 }
581
582 .wcrbp-tab-nav > li > a:active,
583 .wcrbp-tab-nav > li > a:focus {
584 outline : none;
585 box-shadow : none;
586 }
587
588 .wcrbp-tab-nav i,
589 .wcrbp-tab-nav img {
590 vertical-align : middle;
591 margin-right : .3em;
592 }
593
594 .wcrbp-tab-nav i {
595 width : 16px;
596 height : 16px;
597 font-size : 16px;
598 }
599
600 .wcrbp-tab-nav img {
601 width : 12px;
602 height : 12px;
603 display : inline-block;
604 }
605
606 .wcrbp-tab-active > a {
607 color : #333;
608 }
609
610 .wcrbp-tab-panel {
611 padding : 10px 5px 0;
612 border : solid 1px #dfdfdf;
613 background : #fdfdfd;
614 display : none;
615 }
616
617 .wcrbp-tabs-left {
618 overflow : hidden;
619 /* margin: -6px -12px -12px;*/
620 margin : -6px -12px 0;
621 }
622
623 .wcrbp-tabs-left > .wcrbp-tab-nav {
624 float : left;
625 margin : 0 -1px 0 0;
626 background : #fdfdfd;
627 border-right : 1px solid #dfdfdf;
628 z-index : 9;
629 }
630
631 .wcrbp-tabs-left > .wcrbp-tab-nav > li {
632 display : block;
633 }
634
635 .wcrbp-tabs-left > .wcrbp-tab-nav > li:first-child {
636 border-top : none;
637 }
638
639 .wcrbp-tabs-left > .wcrbp-tab-nav > li > a {
640 padding : 5px 20px 8px 10px;
641 }
642
643 .wcrbp-tabs-left > ul > li.wcrbp-tab-active {
644 border : 1px solid #dfdfdf;
645 border-right-color : #fdfdfd;
646 border-left : 2px #2ea2cc;
647 box-shadow : 0 2px 0 rgba(0, 0, 0, 0.02), 0 1px 0 rgba(0, 0, 0, 0.02);
648 position : relative;
649 right : -1px;
650 }
651
652 .wcrbp-tabs-left > .wcrbp-tab-panels {
653 overflow : auto;
654 border-left : 1px solid #dfdfdf;
655 z-index : 1;
656 }
657
658 .wcrbp-tabs-left > .wcrbp-tab-panels > .wcrbp-tab-panel {
659 padding : 3px 20px 0;
660 background : transparent;
661 border : none;
662 }
663
664 .wcrbp-tabs-no-controls {
665 border : 0;
666 background : transparent;
667 }
668
669 .wcrbp-tabs-no-controls .hndle,
670 .wcrbp-tabs-no-controls .handlediv {
671 display : none;
672 }
673
674 .wcrbp-tabs-no-controls .inside {
675 margin : 0;
676 padding : 0;
677 }
678
679 .wcrbp-tabs-box .wcrbp-tab-nav li {
680 background : #ebebeb;
681 border : 1px solid #dedede;
682 margin-right : 5px;
683 }
684
685 .wcrbp-tabs-box .wcrbp-tab-nav li:hover {
686 background : #fff;
687 }
688
689 .wcrbp-tabs-box .wcrbp-tab-nav a {
690 color : #777;
691 }
692
693 .wcrbp-tabs-box .wcrbp-tab-nav .wcrbp-tab-active {
694 border-bottom-color : transparent;
695 }
696
697 .wcrbp-tabs-box .wcrbp-tab-nav .wcrbp-tab-active,
698 .wcrbp-tabs-box .wcrbp-tab-nav .wcrbp-tab-active:hover {
699 background : #f5f5f5;
700 }
701
702 .wcrbp-tabs-box .wcrbp-tab-nav .wcrbp-tab-active a {
703 color : #555;
704 }
705
706 .wcrbp-tabs-box .wcrbp-tab-panel {
707 background : #f5f5f5;
708 border : solid 1px #dedede;
709 }
710
711 .wcrbp-tab-nav .wc-rbp-tab-status {
712 border-radius : 30px;
713 float : right;
714 height : 10px !important;
715 margin-left : 10px;
716 margin-top : 3%;
717 width : 10px !important;
718 }
719
720 .wcrbp-tab-nav .wc-rbp-tab-status.bgred {
721 background : red;
722 }
723
724 .wcrbp-tab-nav .wc-rbp-tab-status.bggreen {
725 background : green;
726 }
727
728 .wcrbp-tab-nav .wc-rbp-tab-status.bgblue {
729 background : #14A4B7;
730 }
1 /**
2 * selectize.css (v0.12.1)
3 * Copyright (c) 2013–2015 Brian Reavis & contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6 * file except in compliance with the License. You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under
10 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11 * ANY KIND, either express or implied. See the License for the specific language
12 * governing permissions and limitations under the License.
13 *
14 * @author Brian Reavis <brian@thirdroute.com>
15 */
16 .selectize-control.plugin-drag_drop.multi > .selectize-input > div.ui-sortable-placeholder {visibility : visible !important;background : #f2f2f2 !important;background : rgba(0, 0, 0, 0.06) !important;border : 0 none !important;-webkit-box-shadow : inset 0 0 12px 4px #ffffff;box-shadow : inset 0 0 12px 4px #ffffff;}
17
18 .selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {content : '!';visibility : hidden;}
19
20 .selectize-control.plugin-drag_drop .ui-sortable-helper {-webkit-box-shadow : 0 2px 5px rgba(0, 0, 0, 0.2);box-shadow : 0 2px 5px rgba(0, 0, 0, 0.2);}
21
22 .selectize-dropdown-header {position : relative;padding : 5px 8px;border-bottom : 1px solid #d0d0d0;background : #f8f8f8;-webkit-border-radius : 3px 3px 0 0;-moz-border-radius : 3px 3px 0 0;border-radius : 3px 3px 0 0;}
23
24 .selectize-dropdown-header-close {position : absolute;right : 8px;top : 50%;color : #303030;opacity : 0.4;margin-top : -12px;line-height : 20px;font-size : 20px !important;}
25
26 .selectize-dropdown-header-close:hover {color : #000000;}
27
28 .selectize-dropdown.plugin-optgroup_columns .optgroup {border-right : 1px solid #f2f2f2;border-top : 0 none;float : left;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;}
29
30 .selectize-dropdown.plugin-optgroup_columns .optgroup:last-child {border-right : 0 none;}
31
32 .selectize-dropdown.plugin-optgroup_columns .optgroup:before {display : none;}
33
34 .selectize-dropdown.plugin-optgroup_columns .optgroup-header {border-top : 0 none;}
35
36 .selectize-control.plugin-remove_button [data-value] {position : relative;padding-right : 24px !important;}
37
38 .selectize-control.plugin-remove_button [data-value] .remove {z-index : 1; /* fixes ie bug (see #392) */position : absolute;top : 0;right : 0;bottom : 0;width : 17px;text-align : center;font-weight : bold;font-size : 12px;color : inherit;text-decoration : none;vertical-align : middle;display : inline-block;padding : 2px 0 0 0;border-left : 1px solid #d0d0d0;-webkit-border-radius : 0 2px 2px 0;-moz-border-radius : 0 2px 2px 0;border-radius : 0 2px 2px 0;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;}
39
40 .selectize-control.plugin-remove_button [data-value] .remove:hover {background : rgba(0, 0, 0, 0.05);}
41
42 .selectize-control.plugin-remove_button [data-value].active .remove {border-left-color : #cacaca;}
43
44 .selectize-control.plugin-remove_button .disabled [data-value] .remove:hover {background : none;}
45
46 .selectize-control.plugin-remove_button .disabled [data-value] .remove {border-left-color : #ffffff;}
47
48 .selectize-control {position : relative;}
49
50 .selectize-dropdown, .selectize-input, .selectize-input input {color : #303030;font-family : inherit;font-size : 13px;line-height : 18px;-webkit-font-smoothing : inherit;}
51
52 .selectize-input, .selectize-control.single .selectize-input.input-active {background : #ffffff;cursor : text;display : inline-block;}
53
54 .selectize-input {border : 1px solid #d0d0d0;padding : 8px 8px;display : inline-block;width : 100%;overflow : hidden;position : relative;z-index : 1;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;-webkit-box-shadow : inset 0 1px 1px rgba(0, 0, 0, 0.1);box-shadow : inset 0 1px 1px rgba(0, 0, 0, 0.1);-webkit-border-radius : 3px;-moz-border-radius : 3px;border-radius : 3px;}
55
56 .selectize-control.multi .selectize-input.has-items {padding : 6px 8px 3px;}
57
58 .selectize-input.full {background-color : #ffffff;}
59
60 .selectize-input.disabled, .selectize-input.disabled * {cursor : default !important;}
61
62 .selectize-input.focus {-webkit-box-shadow : inset 0 1px 2px rgba(0, 0, 0, 0.15);box-shadow : inset 0 1px 2px rgba(0, 0, 0, 0.15);}
63
64 .selectize-input.dropdown-active {-webkit-border-radius : 3px 3px 0 0;-moz-border-radius : 3px 3px 0 0;border-radius : 3px 3px 0 0;}
65
66 .selectize-input > * {vertical-align : baseline;display : -moz-inline-stack;display : inline-block;zoom : 1;*display : inline;}
67
68 .selectize-control.multi .selectize-input > div {cursor : pointer;margin : 0 3px 3px 0;padding : 2px 6px;background : #f2f2f2;color : #303030;border : 0 solid #d0d0d0;}
69
70 .selectize-control.multi .selectize-input > div.active {background : #e8e8e8;color : #303030;border : 0 solid #cacaca;}
71
72 .selectize-control.multi .selectize-input.disabled > div, .selectize-control.multi .selectize-input.disabled > div.active {color : #7d7d7d;background : #ffffff;border : 0 solid #ffffff;}
73
74 .selectize-input > input {display : inline-block !important;padding : 0 !important;min-height : 0 !important;max-height : none !important;max-width : 100% !important;margin : 0 2px 0 0 !important;text-indent : 0 !important;border : 0 none !important;background : none !important;line-height : inherit !important;-webkit-user-select : auto !important;-webkit-box-shadow : none !important;box-shadow : none !important;}
75
76 .selectize-input > input::-ms-clear {display : none;}
77
78 .selectize-input > input:focus {outline : none !important;}
79
80 .selectize-input::after {content : ' ';display : block;clear : left;}
81
82 .selectize-input.dropdown-active::before {content : ' ';display : block;position : absolute;background : #f0f0f0;height : 1px;bottom : 0;left : 0;right : 0;}
83
84 .selectize-dropdown {position : absolute;z-index : 10;border : 1px solid #d0d0d0;background : #ffffff;margin : -1px 0 0 0;border-top : 0 none;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;-webkit-box-shadow : 0 1px 3px rgba(0, 0, 0, 0.1);box-shadow : 0 1px 3px rgba(0, 0, 0, 0.1);-webkit-border-radius : 0 0 3px 3px;-moz-border-radius : 0 0 3px 3px;border-radius : 0 0 3px 3px;}
85
86 .selectize-dropdown [data-selectable] {cursor : pointer;overflow : hidden;}
87
88 .selectize-dropdown [data-selectable] .highlight {background : rgba(125, 168, 208, 0.2);-webkit-border-radius : 1px;-moz-border-radius : 1px;border-radius : 1px;}
89
90 .selectize-dropdown [data-selectable], .selectize-dropdown .optgroup-header {padding : 5px 8px;}
91
92 .selectize-dropdown .optgroup:first-child .optgroup-header {border-top : 0 none;}
93
94 .selectize-dropdown .optgroup-header {color : #303030;background : #ffffff;cursor : default;}
95
96 .selectize-dropdown .active {background-color : #f5fafd;color : #495c68;}
97
98 .selectize-dropdown .active.create {color : #495c68;}
99
100 .selectize-dropdown .create {color : rgba(48, 48, 48, 0.5);}
101
102 .selectize-dropdown-content {overflow-y : auto;overflow-x : hidden;max-height : 200px;}
103
104 .selectize-control.single .selectize-input, .selectize-control.single .selectize-input input {cursor : pointer;}
105
106 .selectize-control.single .selectize-input.input-active, .selectize-control.single .selectize-input.input-active input {cursor : text;}
107
108 .selectize-control.single .selectize-input:after {content : ' ';display : block;position : absolute;top : 50%;right : 15px;margin-top : -3px;width : 0;height : 0;border-style : solid;border-width : 5px 5px 0 5px;border-color : #808080 transparent transparent transparent;}
109
110 .selectize-control.single .selectize-input.dropdown-active:after {margin-top : -4px;border-width : 0 5px 5px 5px;border-color : transparent transparent #808080 transparent;}
111
112 .selectize-control.rtl.single .selectize-input:after {left : 15px;right : auto;}
113
114 .selectize-control.rtl .selectize-input > input {margin : 0 4px 0 -2px !important;}
115
116 .selectize-control .selectize-input.disabled {opacity : 0.5;background-color : #fafafa;}
117
118 /*** selectize.default.css (v0.12.1) - Default Theme* Copyright (c) 2013–2015 Brian Reavis & contributors** Licensed under the Apache License, Version 2.0 (the "License"); you may not use this* file except in compliance with the License. You may obtain a copy of the License at:* http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software distributed under* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF* ANY KIND, either express or implied. See the License for the specific language* governing permissions and limitations under the License.** @author Brian Reavis <brian@thirdroute.com>*/
119 .selectize-control.plugin-drag_drop.multi > .selectize-input > div.ui-sortable-placeholder {visibility : visible !important;background : #f2f2f2 !important;background : rgba(0, 0, 0, 0.06) !important;border : 0 none !important;-webkit-box-shadow : inset 0 0 12px 4px #ffffff;box-shadow : inset 0 0 12px 4px #ffffff;}
120
121 .selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {content : '!';visibility : hidden;}
122
123 .selectize-control.plugin-drag_drop .ui-sortable-helper {-webkit-box-shadow : 0 2px 5px rgba(0, 0, 0, 0.2);box-shadow : 0 2px 5px rgba(0, 0, 0, 0.2);}
124
125 .selectize-dropdown-header {position : relative;padding : 5px 8px;border-bottom : 1px solid #d0d0d0;background : #f8f8f8;-webkit-border-radius : 3px 3px 0 0;-moz-border-radius : 3px 3px 0 0;border-radius : 3px 3px 0 0;}
126
127 .selectize-dropdown-header-close {position : absolute;right : 8px;top : 50%;color : #303030;opacity : 0.4;margin-top : -12px;line-height : 20px;font-size : 20px !important;}
128
129 .selectize-dropdown-header-close:hover {color : #000000;}
130
131 .selectize-dropdown.plugin-optgroup_columns .optgroup {border-right : 1px solid #f2f2f2;border-top : 0 none;float : left;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;}
132
133 .selectize-dropdown.plugin-optgroup_columns .optgroup:last-child {border-right : 0 none;}
134
135 .selectize-dropdown.plugin-optgroup_columns .optgroup:before {display : none;}
136
137 .selectize-dropdown.plugin-optgroup_columns .optgroup-header {border-top : 0 none;}
138
139 .selectize-control.plugin-remove_button [data-value] {position : relative;padding-right : 24px !important;}
140
141 .selectize-control.plugin-remove_button [data-value] .remove {z-index : 1; /* fixes ie bug (see #392) */position : absolute;top : 0;right : 0;bottom : 0;width : 17px;text-align : center;font-weight : bold;font-size : 12px;color : inherit;text-decoration : none;vertical-align : middle;display : inline-block;padding : 2px 0 0 0;border-left : 1px solid #0073bb;-webkit-border-radius : 0 2px 2px 0;-moz-border-radius : 0 2px 2px 0;border-radius : 0 2px 2px 0;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;}
142
143 .selectize-control.plugin-remove_button [data-value] .remove:hover {background : rgba(0, 0, 0, 0.05);}
144
145 .selectize-control.plugin-remove_button [data-value].active .remove {border-left-color : #00578d;}
146
147 .selectize-control.plugin-remove_button .disabled [data-value] .remove:hover {background : none;}
148
149 .selectize-control.plugin-remove_button .disabled [data-value] .remove {border-left-color : #aaaaaa;}
150
151 .selectize-control {position : relative;}
152
153 .selectize-dropdown, .selectize-input, .selectize-input input {color : #303030;font-family : inherit;font-size : 13px;line-height : 18px;-webkit-font-smoothing : inherit;}
154
155 .selectize-input, .selectize-control.single .selectize-input.input-active {background : #ffffff;cursor : text;display : inline-block;}
156
157 .selectize-input {border : 1px solid #d0d0d0;padding : 8px 8px;display : inline-block;width : 100%;overflow : hidden;position : relative;z-index : 1;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;-webkit-box-shadow : inset 0 1px 1px rgba(0, 0, 0, 0.1);box-shadow : inset 0 1px 1px rgba(0, 0, 0, 0.1);-webkit-border-radius : 3px;-moz-border-radius : 3px;border-radius : 3px;}
158
159 .selectize-control.multi .selectize-input.has-items {padding : 5px 8px 2px;}
160
161 .selectize-input.full {background-color : #ffffff;}
162
163 .selectize-input.disabled, .selectize-input.disabled * {cursor : default !important;}
164
165 .selectize-input.focus {-webkit-box-shadow : inset 0 1px 2px rgba(0, 0, 0, 0.15);box-shadow : inset 0 1px 2px rgba(0, 0, 0, 0.15);}
166
167 .selectize-input.dropdown-active {-webkit-border-radius : 3px 3px 0 0;-moz-border-radius : 3px 3px 0 0;border-radius : 3px 3px 0 0;}
168
169 .selectize-input > * {vertical-align : baseline;display : -moz-inline-stack;display : inline-block;zoom : 1;*display : inline;}
170
171 .selectize-control.multi .selectize-input > div {cursor : pointer;margin : 0 3px 3px 0;padding : 2px 6px;background : #1da7ee;color : #ffffff;border : 1px solid #0073bb;}
172
173 .selectize-control.multi .selectize-input > div.active {background : #92c836;color : #ffffff;border : 1px solid #00578d;}
174
175 .selectize-control.multi .selectize-input.disabled > div, .selectize-control.multi .selectize-input.disabled > div.active {color : #ffffff;background : #d2d2d2;border : 1px solid #aaaaaa;}
176
177 .selectize-input > input {display : inline-block !important;padding : 0 !important;min-height : 0 !important;max-height : none !important;max-width : 100% !important;margin : 0 1px !important;text-indent : 0 !important;border : 0 none !important;background : none !important;line-height : inherit !important;-webkit-user-select : auto !important;-webkit-box-shadow : none !important;box-shadow : none !important;}
178
179 .selectize-input > input::-ms-clear {display : none;}
180
181 .selectize-input > input:focus {outline : none !important;}
182
183 .selectize-input::after {content : ' ';display : block;clear : left;}
184
185 .selectize-input.dropdown-active::before {content : ' ';display : block;position : absolute;background : #f0f0f0;height : 1px;bottom : 0;left : 0;right : 0;}
186
187 .selectize-dropdown {position : absolute;z-index : 10;border : 1px solid #d0d0d0;background : #ffffff;margin : -1px 0 0 0;border-top : 0 none;-webkit-box-sizing : border-box;-moz-box-sizing : border-box;box-sizing : border-box;-webkit-box-shadow : 0 1px 3px rgba(0, 0, 0, 0.1);box-shadow : 0 1px 3px rgba(0, 0, 0, 0.1);-webkit-border-radius : 0 0 3px 3px;-moz-border-radius : 0 0 3px 3px;border-radius : 0 0 3px 3px;}
188
189 .selectize-dropdown [data-selectable] {cursor : pointer;overflow : hidden;}
190
191 .selectize-dropdown [data-selectable] .highlight {background : rgba(125, 168, 208, 0.2);-webkit-border-radius : 1px;-moz-border-radius : 1px;border-radius : 1px;}
192
193 .selectize-dropdown [data-selectable], .selectize-dropdown .optgroup-header {padding : 5px 8px;}
194
195 .selectize-dropdown .optgroup:first-child .optgroup-header {border-top : 0 none;}
196
197 .selectize-dropdown .optgroup-header {color : #303030;background : #ffffff;cursor : default;}
198
199 .selectize-dropdown .active {background-color : #f5fafd;color : #495c68;}
200
201 .selectize-dropdown .active.create {color : #495c68;}
202
203 .selectize-dropdown .create {color : rgba(48, 48, 48, 0.5);}
204
205 .selectize-dropdown-content {overflow-y : auto;overflow-x : hidden;max-height : 200px;}
206
207 .selectize-control.single .selectize-input, .selectize-control.single .selectize-input input {cursor : pointer;}
208
209 .selectize-control.single .selectize-input.input-active, .selectize-control.single .selectize-input.input-active input {cursor : text;}
210
211 .selectize-control.single .selectize-input:after {content : ' ';display : block;position : absolute;top : 50%;right : 15px;margin-top : -3px;width : 0;height : 0;border-style : solid;border-width : 5px 5px 0 5px;border-color : #808080 transparent transparent transparent;}
212
213 .selectize-control.single .selectize-input.dropdown-active:after {margin-top : -4px;border-width : 0 5px 5px 5px;border-color : transparent transparent #808080 transparent;}
214
215 .selectize-control.rtl.single .selectize-input:after {left : 15px;right : auto;}
216
217 .selectize-control.rtl .selectize-input > input {margin : 0 4px 0 -2px !important;}
218
219 .selectize-control .selectize-input.disabled {opacity : 0.5;background-color : #fafafa;}
220
221 .selectize-control.multi .selectize-input.has-items {padding-left : 5px;padding-right : 5px;}
222
223 .selectize-control.multi .selectize-input.disabled [data-value] {color : #999;text-shadow : none;background : none;-webkit-box-shadow : none;box-shadow : none;}
224
225 .selectize-control.multi .selectize-input.disabled [data-value], .selectize-control.multi .selectize-input.disabled [data-value] .remove {border-color : #e6e6e6;}
226
227 .selectize-control.multi .selectize-input.disabled [data-value] .remove {background : none;}
228
229 .selectize-control.multi .selectize-input [data-value] {text-shadow : 0 1px 0 rgba(0, 51, 83, 0.3);-webkit-border-radius : 3px;-moz-border-radius : 3px;border-radius : 3px;background-color : #1b9dec;background-image : -moz-linear-gradient(top, #1da7ee, #178ee9);background-image : -webkit-gradient(linear, 0 0, 0 100%, from(#1da7ee), to(#178ee9));background-image : -webkit-linear-gradient(top, #1da7ee, #178ee9);background-image : -o-linear-gradient(top, #1da7ee, #178ee9);background-image : linear-gradient(to bottom, #1da7ee, #178ee9);background-repeat : repeat-x;filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff1da7ee', endColorstr='#ff178ee9', GradientType=0);-webkit-box-shadow : 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.03);box-shadow : 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.03);}
230
231 .selectize-control.multi .selectize-input [data-value].active {background-color : #0085d4;background-image : -moz-linear-gradient(top, #008fd8, #0075cf);background-image : -webkit-gradient(linear, 0 0, 0 100%, from(#008fd8), to(#0075cf));background-image : -webkit-linear-gradient(top, #008fd8, #0075cf);background-image : -o-linear-gradient(top, #008fd8, #0075cf);background-image : linear-gradient(to bottom, #008fd8, #0075cf);background-repeat : repeat-x;filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff008fd8', endColorstr='#ff0075cf', GradientType=0);}
232
233 .selectize-control.single .selectize-input {-webkit-box-shadow : 0 1px 0 rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8);box-shadow : 0 1px 0 rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8);background-color : #f9f9f9;background-image : -moz-linear-gradient(top, #fefefe, #f2f2f2);background-image : -webkit-gradient(linear, 0 0, 0 100%, from(#fefefe), to(#f2f2f2));background-image : -webkit-linear-gradient(top, #fefefe, #f2f2f2);background-image : -o-linear-gradient(top, #fefefe, #f2f2f2);background-image : linear-gradient(to bottom, #fefefe, #f2f2f2);background-repeat : repeat-x;filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffefefe', endColorstr='#fff2f2f2', GradientType=0);}
234
235 .selectize-control.single .selectize-input, .selectize-dropdown.single {border-color : #b8b8b8;}
236
237 .selectize-dropdown .optgroup-header {padding-top : 7px;font-weight : bold;font-size : 0.85em;}
238
239 .selectize-dropdown .optgroup {border-top : 1px solid #f0f0f0;}
240
241 .selectize-dropdown .optgroup:first-child {border-top : 0 none;}
...\ No newline at end of file ...\ No newline at end of file
1 .pws_tabs_container.pws_scale .pws_hide,.pws_tabs_list{-moz-transition:all .3s ease-in-out .3s;-o-transition:all .3s ease-in-out .3s}.pws_tabs_container,.pws_tabs_controll a{font-size:16px}@media only screen and (max-width:60em){.pws_tabs_container.pws_tabs_responsive{width:100%!important}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll{width:100%}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll li{vertical-align:top;text-align:center}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll li a{margin:0;font-size:1em;line-height:1.125em;overflow:hidden}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll li a i{display:block;margin:0 0 5px}.pws_tabs_container.pws_tabs_responsive.pws_tabs_vertical{display:block;position:relative}.pws_tabs_container.pws_tabs_responsive.pws_tabs_vertical:after{display:block;content:'';clear:both}.pws_tabs_container.pws_tabs_responsive.pws_tabs_vertical ul.pws_tabs_controll{width:100%;position:relative;float:none}.pws_tabs_container.pws_tabs_responsive.pws_tabs_vertical ul.pws_tabs_controll li{display:inline-block}.pws_tabs_container.pws_tabs_responsive.pws_tabs_vertical ul.pws_tabs_controll li a{margin:0}.pws_tabs_container.pws_tabs_responsive.pws_tabs_vertical .pws_tabs_list{position:relative;float:none}}@media only screen and (max-width:37.5em){.pws_tabs_container.pws_tabs_responsive{width:100%!important;position:relative}.pws_tabs_container.pws_tabs_responsive .pws_responsive_small_menu{width:100%;height:40px;background-color:#9bd7d5;display:block}.pws_tabs_container.pws_tabs_responsive .pws_responsive_small_menu a{width:40px;height:40px;display:block;overflow:hidden;color:#fff;font-size:32px;font-size:2em;text-align:center;padding:3px 0 0;cursor:pointer;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}.pws_tabs_container.pws_tabs_responsive .pws_responsive_small_menu a:hover{background-color:#70c5c2}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll.pws_tabs_menu_popup{display:block;position:absolute;overflow:hidden;top:40px;left:0;z-index:99;margin:0;padding:0;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll.pws_tabs_menu_popup li{display:block;float:none}.pws_tabs_container.pws_tabs_responsive ul.pws_tabs_controll.pws_tabs_menu_popup li a i{display:inline-block;margin:0 .1875em 0 0}.pws_tabs_container.pws_tabs_responsive.pws_tabs_rtl ul.pws_tabs_controll.pws_tabs_menu_popup li a i{display:inline-block;margin:0 0 0 .1875em}}.pws_tabs_container{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pws_tabs_container ul.pws_tabs_controll{list-style:none;margin:0;padding:0}.pws_tabs_container ul.pws_tabs_controll li{display:inline-block}.pws_tabs_container ul.pws_tabs_controll li a{display:block;background-color:#9bd7d5;padding:.9375em 1.25em;text-decoration:none;color:#fff;margin-right:3px;cursor:pointer}.pws_tabs_container ul.pws_tabs_controll li a:hover{background-color:#70c5c2}.pws_tabs_container ul.pws_tabs_controll li a i{margin-right:8px}.pws_tabs_container ul.pws_tabs_controll li a.pws_tab_noname i{margin-right:0;margin-left:0}.pws_tabs_container ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff;color:#505050}.pws_tabs_list{display:block;background-color:#fff;height:auto;padding:1.25em;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-transition:all .3s ease-in-out .3s;transition:all .3s ease-in-out .3s;overflow:hidden;position:relative}.pws_tab_single{display:block;-webkit-transition:all .3s ease-in-out 0;-moz-transition:all .3s ease-in-out 0;-o-transition:all .3s ease-in-out 0;transition:all .3s ease-in-out 0}.pws_tabs_container.pws_tabs_rtl{text-align:right;direction:rtl}.pws_tabs_container.pws_tabs_rtl ul.pws_tabs_controll li a{margin-right:0;margin-left:3px}.pws_tabs_container.pws_tabs_rtl ul.pws_tabs_controll li a i{margin-left:8px;margin-right:0}.pws_tabs_container.pws_tabs_vertical{display:block;position:relative}.pws_tabs_container.pws_tabs_vertical:after{display:block;content:'';clear:both}.pws_tabs_container.pws_tabs_vertical>ul.pws_tabs_controll{width:auto;position:relative;float:left}.pws_tabs_container.pws_tabs_vertical>ul.pws_tabs_controll li{display:block}.pws_tabs_container.pws_tabs_vertical>ul.pws_tabs_controll li a{margin-right:0;margin-left:0;margin-bottom:3px}.pws_tabs_container.pws_tabs_vertical>.pws_tabs_list{position:relative;float:left}.pws_tabs_container.pws_tabs_responsive.pws_theme_violet .pws_responsive_small_menu{background-color:#c72c66}.pws_tabs_container.pws_tabs_responsive.pws_theme_violet .pws_responsive_small_menu a:hover{background-color:#a6164c}.pws_tabs_container.pws_theme_violet ul.pws_tabs_controll li a{background-color:#c72c66}.pws_tabs_container.pws_theme_violet ul.pws_tabs_controll li a:hover{background-color:#a6164c}.pws_tabs_container.pws_theme_violet ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_green .pws_responsive_small_menu{background-color:#86c447}.pws_tabs_container.pws_tabs_responsive.pws_theme_green .pws_responsive_small_menu a:hover{background-color:#539312}.pws_tabs_container.pws_theme_green ul.pws_tabs_controll li a{background-color:#86c447}.pws_tabs_container.pws_theme_green ul.pws_tabs_controll li a:hover{background-color:#539312}.pws_tabs_container.pws_theme_green ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_yellow .pws_responsive_small_menu{background-color:#fdb813}.pws_tabs_container.pws_tabs_responsive.pws_theme_yellow .pws_responsive_small_menu a:hover{background-color:orange}.pws_tabs_container.pws_theme_yellow ul.pws_tabs_controll li a{background-color:#fdb813}.pws_tabs_container.pws_theme_yellow ul.pws_tabs_controll li a:hover{background-color:orange}.pws_tabs_container.pws_theme_yellow ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_gold .pws_responsive_small_menu{background-color:#f89827}.pws_tabs_container.pws_tabs_responsive.pws_theme_gold .pws_responsive_small_menu a:hover{background-color:#fa7b00}.pws_tabs_container.pws_theme_gold ul.pws_tabs_controll li a{background-color:#f89827}.pws_tabs_container.pws_theme_gold ul.pws_tabs_controll li a:hover{background-color:#fa7b00}.pws_tabs_container.pws_theme_gold ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_orange .pws_responsive_small_menu{background-color:#f15b42}.pws_tabs_container.pws_tabs_responsive.pws_theme_orange .pws_responsive_small_menu a:hover{background-color:#fd2e0b}.pws_tabs_container.pws_theme_orange ul.pws_tabs_controll li a{background-color:#f15b42}.pws_tabs_container.pws_theme_orange ul.pws_tabs_controll li a:hover{background-color:#fd2e0b}.pws_tabs_container.pws_theme_orange ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_red .pws_responsive_small_menu{background-color:#e41937}.pws_tabs_container.pws_tabs_responsive.pws_theme_red .pws_responsive_small_menu a:hover{background-color:#d70726}.pws_tabs_container.pws_theme_red ul.pws_tabs_controll li a{background-color:#e41937}.pws_tabs_container.pws_theme_red ul.pws_tabs_controll li a:hover{background-color:#d70726}.pws_tabs_container.pws_theme_red ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_purple .pws_responsive_small_menu{background-color:#672e8d}.pws_tabs_container.pws_tabs_responsive.pws_theme_purple .pws_responsive_small_menu a:hover{background-color:#470871}.pws_tabs_container.pws_theme_purple ul.pws_tabs_controll li a{background-color:#672e8d}.pws_tabs_container.pws_theme_purple ul.pws_tabs_controll li a:hover{background-color:#470871}.pws_tabs_container.pws_theme_purple ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_grey .pws_responsive_small_menu{background-color:#4d4d4f}.pws_tabs_container.pws_tabs_responsive.pws_theme_grey .pws_responsive_small_menu a:hover{background-color:#000}.pws_tabs_container.pws_theme_grey ul.pws_tabs_controll li a{background-color:#4d4d4f}.pws_tabs_container.pws_theme_grey ul.pws_tabs_controll li a:hover{background-color:#000}.pws_tabs_container.pws_theme_grey ul.pws_tabs_controll li a.pws_tab_active{background-color:#fff}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_violet .pws_responsive_small_menu{background-color:#c72c66}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_violet .pws_responsive_small_menu a:hover{background-color:#a6164c}.pws_tabs_container.pws_theme_dark_violet .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_violet ul.pws_tabs_controll li a{background-color:#c72c66}.pws_tabs_container.pws_theme_dark_violet ul.pws_tabs_controll li a:hover{background-color:#a6164c}.pws_tabs_container.pws_theme_dark_violet ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_green .pws_responsive_small_menu{background-color:#86c447}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_green .pws_responsive_small_menu a:hover{background-color:#539312}.pws_tabs_container.pws_theme_dark_green .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_green ul.pws_tabs_controll li a{background-color:#86c447}.pws_tabs_container.pws_theme_dark_green ul.pws_tabs_controll li a:hover{background-color:#539312}.pws_tabs_container.pws_theme_dark_green ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_yellow .pws_responsive_small_menu{background-color:#fdb813}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_yellow .pws_responsive_small_menu a:hover{background-color:orange}.pws_tabs_container.pws_theme_dark_yellow .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_yellow ul.pws_tabs_controll li a{background-color:#fdb813}.pws_tabs_container.pws_theme_dark_yellow ul.pws_tabs_controll li a:hover{background-color:orange}.pws_tabs_container.pws_theme_dark_yellow ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_gold .pws_responsive_small_menu{background-color:#f89827}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_gold .pws_responsive_small_menu a:hover{background-color:#fa7b00}.pws_tabs_container.pws_theme_dark_gold .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_gold ul.pws_tabs_controll li a{background-color:#f89827}.pws_tabs_container.pws_theme_dark_gold ul.pws_tabs_controll li a:hover{background-color:#fa7b00}.pws_tabs_container.pws_theme_dark_gold ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_orange .pws_responsive_small_menu{background-color:#f15b42}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_orange .pws_responsive_small_menu a:hover{background-color:#fd2e0b}.pws_tabs_container.pws_theme_dark_orange .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_orange ul.pws_tabs_controll li a{background-color:#f15b42}.pws_tabs_container.pws_theme_dark_orange ul.pws_tabs_controll li a:hover{background-color:#fd2e0b}.pws_tabs_container.pws_theme_dark_orange ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_red .pws_responsive_small_menu{background-color:#e41937}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_red .pws_responsive_small_menu a:hover{background-color:#d70726}.pws_tabs_container.pws_theme_dark_red .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_red ul.pws_tabs_controll li a{background-color:#e41937}.pws_tabs_container.pws_theme_dark_red ul.pws_tabs_controll li a:hover{background-color:#d70726}.pws_tabs_container.pws_theme_dark_red ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_purple .pws_responsive_small_menu{background-color:#672e8d}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_purple .pws_responsive_small_menu a:hover{background-color:#470871}.pws_tabs_container.pws_theme_dark_purple .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_purple ul.pws_tabs_controll li a{background-color:#672e8d}.pws_tabs_container.pws_theme_dark_purple ul.pws_tabs_controll li a:hover{background-color:#470871}.pws_tabs_container.pws_theme_dark_purple ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_grey .pws_responsive_small_menu{background-color:#4d4d4f}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_grey .pws_responsive_small_menu a:hover{background-color:#000}.pws_tabs_container.pws_theme_dark_grey .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_grey ul.pws_tabs_controll li a{background-color:#4d4d4f}.pws_tabs_container.pws_theme_dark_grey ul.pws_tabs_controll li a:hover{background-color:#000}.pws_tabs_container.pws_theme_dark_grey ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_cyan .pws_responsive_small_menu{background-color:#9bd7d5}.pws_tabs_container.pws_tabs_responsive.pws_theme_dark_cyan .pws_responsive_small_menu a:hover{background-color:#70c5c2}.pws_tabs_container.pws_theme_dark_cyan .pws_tabs_list{background-color:#fafafa}.pws_tabs_container.pws_theme_dark_cyan ul.pws_tabs_controll li a{background-color:#9bd7d5}.pws_tabs_container.pws_theme_dark_cyan ul.pws_tabs_controll li a:hover{background-color:#70c5c2}.pws_tabs_container.pws_theme_dark_cyan ul.pws_tabs_controll li a.pws_tab_active{background-color:#fafafa}.pws_tabs_noeffect .pws_tabs_list{-webkit-transition:all .1s ease-in-out 0;-moz-transition:all .1s ease-in-out 0;-o-transition:all .1s ease-in-out 0;transition:all .1s ease-in-out 0}.pws_tabs_noeffect .pws_tab_single{-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.pws_tabs_container.pws_none .pws_hide{display:none}.pws_tabs_container.pws_none .pws_show{display:block}.pws_tabs_container.pws_scale .pws_hide{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;-webkit-transform:scale(.9);-moz-transform:scale(.9);-o-transform:scale(.9);-ms-transform:scale(.9);transform:scale(.9);-webkit-transition:all .3s ease-in-out .3s;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_scale .pws_show,.pws_tabs_container.pws_slideleft .pws_hide{-webkit-transition:all .3s ease-in-out .3s;-moz-transition:all .3s ease-in-out .3s;-o-transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_scale .pws_show{z-index:1;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;-webkit-transform:scale(1);-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);transform:scale(1);transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slideleft .pws_hide{-webkit-transform:translateX(-100%);-moz-transform:translateX(-100%);-o-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slideleft .pws_show,.pws_tabs_container.pws_slideright .pws_hide{-webkit-transition:all .3s ease-in-out .3s;-moz-transition:all .3s ease-in-out .3s;-o-transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slideleft .pws_show{-webkit-transform:translateX(0);-moz-transform:translateX(0);-o-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slideright .pws_hide{-webkit-transform:translateX(200%);-moz-transform:translateX(200%);-o-transform:translateX(200%);-ms-transform:translateX(200%);transform:translateX(200%);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slideright .pws_show,.pws_tabs_container.pws_slidetop .pws_hide{-webkit-transition:all .3s ease-in-out .3s;-moz-transition:all .3s ease-in-out .3s;-o-transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slideright .pws_show{-webkit-transform:translateX(0);-moz-transform:translateX(0);-o-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slidetop .pws_hide{-webkit-transform:translateY(-100%);-moz-transform:translateY(-100%);-o-transform:translateY(-100%);-ms-transform:translateY(-100%);transform:translateY(-100%);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slidedown .pws_hide,.pws_tabs_container.pws_slidetop .pws_show{-webkit-transition:all .3s ease-in-out .3s;-moz-transition:all .3s ease-in-out .3s;-o-transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slidetop .pws_show{-webkit-transform:translateY(0);-moz-transform:translateY(0);-o-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slidedown .pws_hide{-webkit-transform:translateY(200%);-moz-transform:translateY(200%);-o-transform:translateY(200%);-ms-transform:translateY(200%);transform:translateY(200%);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;transition:all .3s ease-in-out .3s}.pws_tabs_container.pws_slidedown .pws_show{-webkit-transform:translateY(0);-moz-transform:translateY(0);-o-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;-webkit-transition:all .3s ease-in-out .3s;-moz-transition:all .3s ease-in-out .3s;-o-transition:all .3s ease-in-out .3s;transition:all .3s ease-in-out .3s}
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Common Plugin Functions
4 *
5 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
6 * @package Role Based Price For WooCommerce
7 * @subpackage Role Based Price For WooCommerce/core
8 * @since 3.0
9 */
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 global $wc_rbp_db_settins_values, $wc_rbp_db_array;
15 $wc_rbp_db_settins_values = array();
16 $wc_rbp_db_array = array();
17 add_action( 'wc_rbp_loaded', 'wc_rbp_get_settings_from_db' );
18
19 if ( ! function_exists( 'wc_rbp_option' ) ) {
20 function wc_rbp_option( $key = '', $return_failure = '' ) {
21 global $wc_rbp_db_settins_values;
22 if ( $key == '' ) {
23 return $wc_rbp_db_settins_values;
24 }
25
26 if ( isset( $wc_rbp_db_settins_values[ WC_RBP_DB . $key ] ) ) {
27 return $wc_rbp_db_settins_values[ WC_RBP_DB . $key ];
28 }
29
30 return $return_failure;
31 }
32
33 }
34
35 if ( ! function_exists( 'wc_rbp_get_settings_from_db' ) ) {
36 /**
37 * Retrives All Plugin Options From DB
38 */
39 function wc_rbp_get_settings_from_db() {
40 global $wc_rbp_db_settins_values;
41 $section = array();
42 $section = apply_filters( 'wc_rbp_settings_section', $section );
43 $values = array();
44
45 foreach ( $section as $settings ) {
46 foreach ( $settings as $set ) {
47 $db_val = get_option( WC_RBP_DB . $set['id'] );
48 if ( is_array( $db_val ) ) {
49 unset( $db_val['section_id'] );
50 $values = array_merge( $db_val, $values );
51 }
52 }
53 }
54 $wc_rbp_db_settins_values = $values;
55 }
56 }
57
58 if ( ! function_exists( 'wc_rbp_is_request' ) ) {
59 /**
60 * What type of request is this?
61 * string $type ajax, frontend or admin
62 *
63 * @return bool
64 */
65 function wc_rbp_is_request( $type ) {
66 switch ( $type ) {
67 case 'admin' :
68 return is_admin();
69 case 'ajax' :
70 return defined( 'DOING_AJAX' );
71 case 'cron' :
72 return defined( 'DOING_CRON' );
73 case 'frontend' :
74 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
75 }
76 }
77 }
78
79 if ( ! function_exists( 'wc_rbp_current_screen' ) ) {
80 /**
81 * Gets Current Screen ID from wordpress
82 *
83 * @return string [Current Screen ID]
84 */
85 function wc_rbp_current_screen() {
86 $screen = get_current_screen();
87 return $screen->id;
88 }
89 }
90
91 if ( ! function_exists( 'wc_rbp_get_screen_ids' ) ) {
92 /**
93 * Returns Predefined Screen IDS
94 *
95 * @return [Array]
96 */
97 function wc_rbp_get_screen_ids() {
98 $screen_ids = array();
99 $screen_ids[] = 'woocommerce_page_woocommerce-role-based-price-settings';
100 return $screen_ids;
101 }
102 }
103
104 if ( ! function_exists( 'wc_rbp_dependency_message' ) ) {
105 /**
106 * Returns the plugin dependency message
107 */
108 function wc_rbp_dependency_message() {
109 $text = __( WC_RBP_NAME . ' requires <b> WooCommerce </b> To Be Installed.. <br/> <i>Plugin Deactivated</i> ', WC_RBP_TXT );
110 return $text;
111 }
112 }
113
114 if ( ! function_exists( 'wc_rbp_custom_wp_user_roles' ) ) {
115 function wc_rbp_custom_wp_user_roles() {
116 $all_roles = array();
117 if ( function_exists( 'wp_roles' ) ) {
118 $all_roles = wp_roles()->roles;
119 }
120 return $all_roles;
121 }
122 }
123
124 if ( ! function_exists( 'wc_rbp_get_wp_roles' ) ) {
125 /**
126 * Returns Registered WP User Roles
127 *
128 * @return [[Type]] [[Description]]
129 */
130 function wc_rbp_get_wp_roles() {
131 $user_roles = wc_rbp_custom_wp_user_roles();
132 $user_roles['logedout'] = array( 'name' => __( 'Visitor / LogedOut User', WC_RBP_TXT ) );
133 $user_roles = apply_filters( 'wc_rbp_wp_user_roles', $user_roles );
134 return $user_roles;
135 }
136
137 }
138
139 if ( ! function_exists( 'wc_rbp_get_template' ) ) {
140 function wc_rbp_get_template( $name, $args = array(), $main_path = '', $theme_path = 'woocommerce' ) {
141 if ( empty( $main_path ) ) {
142 $main_path = WC_RBP_PATH . '/templates/';
143 }
144 ob_start();
145 wc_get_template( $name, $args, $theme_path, $main_path );
146 $return_value = ob_get_clean();
147 ob_flush();
148
149 return $return_value;
150 }
151 }
152
153 if ( ! function_exists( 'wc_rbp_get_user_roles_selectbox' ) ) {
154 function wc_rbp_get_user_roles_selectbox() {
155 $user_roles = wc_rbp_get_wp_roles();
156 $list_roles = array();
157 $roles = array_keys( $user_roles );
158 foreach ( $roles as $role ) {
159 $list_roles[ $role ] = $user_roles[ $role ]['name'];
160 }
161 return $list_roles;
162 }
163
164 }
165
166 if ( ! function_exists( 'wc_rbp_get_current_user' ) ) {
167 /**
168 * Gets Current Logged in User Role / User Object.
169 * returns user role if $userroleonly set to true
170 * or returns the user object
171 *
172 * @param [boolean] [$userroleonly = true / false]
173 *
174 * @return [string / object]
175 */
176 function wc_rbp_get_current_user( $userroleonly = true ) {
177 global $current_user;
178 $user_role = $current_user;
179 if ( $userroleonly ) {
180 $user_roles = $current_user->roles;
181 $user_role = array_shift( $user_roles );
182 if ( $user_role == null ) {
183 $user_role = 'logedout';
184 }
185 }
186
187 return apply_filters( 'wc_rbp_active_user', $user_role, $userroleonly );
188 }
189
190 }
191
192 if ( ! function_exists( 'wc_rbp_get_oppo_metakey' ) ) {
193 function wc_rbp_get_oppo_metakey( $key ) {
194 if ( $key == 'selling_price' ) {
195 return 'regular_price';
196 }
197 return 'selling_price';
198 }
199 }
200
201 if ( ! function_exists( 'wc_rbp_get_userrole_by_id' ) ) {
202
203 /**
204 * Get user roles by user ID.
205 *
206 * @param int $id
207 *
208 * @return array
209 */
210 function wc_rbp_get_userrole_by_id( $id ) {
211 $user = new WP_User( $id );
212 if ( empty ( $user->roles ) or ! is_array( $user->roles ) ) {
213 return '';
214 }
215 foreach ( $user->roles as $role ) {
216 return $role;
217 }
218 return null;
219 }
220 }
221
222 if ( ! function_exists( 'wc_rbp_avaiable_price_type' ) ) {
223 /**
224 * Returns avaiable_price type with label
225 *
226 * @return [[Type]] [[Description]]
227 */
228 function wc_rbp_avaiable_price_type( $key = '' ) {
229 $avaiable_price = array();
230 $avaiable_price['regular_price'] = __( 'Regular Price', WC_RBP_TXT );
231 $avaiable_price['selling_price'] = __( 'Selling Price', WC_RBP_TXT );
232 $avaiable_price = apply_filters( 'wc_rbp_avaiable_price', $avaiable_price );
233
234 if ( ! empty( $key ) ) {
235 if ( isset( $avaiable_price[ $key ] ) ) {
236 return $avaiable_price[ $key ];
237 }
238 }
239
240 return $avaiable_price;
241 }
242 }
243
244 if ( ! function_exists( 'wc_rbp_price_types' ) ) {
245 function wc_rbp_price_types( $key = '' ) {
246 $price = wc_rbp_avaiable_price_type();
247 foreach ( $price as $price_id => $priceVal ) {
248 $lable = wc_rbp_option( $price_id . '_label', $priceVal );
249 $price[ $price_id ] = $lable;
250 }
251
252 if ( ! empty( $key ) ) {
253 if ( isset( $price[ $key ] ) ) {
254 return $price[ $key ];
255 }
256 }
257
258 return $price;
259 }
260 }
261
262 if ( ! function_exists( 'wc_rbp_do_settings_sections' ) ) {
263 /**
264 * Prints out all settings sections added to a particular settings page
265 *
266 * Part of the Settings API. Use this in a settings page callback function
267 * to output all the sections and fields that were added to that $page with
268 * add_settings_section() and add_settings_field()
269 *
270 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
271 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
272 * @since 2.7.0
273 *
274 * @param string $page The slug name of the page whose settings sections you want to output
275 */
276 function wc_rbp_do_settings_sections( $page ) {
277 global $wp_settings_sections, $wp_settings_fields;
278
279 if ( ! isset( $wp_settings_sections[ $page ] ) )
280 return;
281 $section_count = count( $wp_settings_sections[ $page ] );
282 if ( $section_count > 1 ) {
283 echo '<ul class="subsubsub wc_rbp_settings_submenu">';
284 foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
285 echo '<li> <a href="#' . $section['id'] . '">' . $section['title'] . '</a> | </li>';
286 }
287 echo '</ul> <br/>';
288 }
289
290 foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
291 if ( $section_count > 1 ) {
292 echo '<div id="settings_' . $section['id'] . '" class="hidden wc_rbp_settings_content">';
293 }
294 if ( $section['title'] )
295 echo "<h2>{$section['title']}</h2>\n";
296
297 if ( $section['callback'] )
298 call_user_func( $section['callback'], $section );
299
300 if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) )
301 continue;
302 echo '<table class="form-table">';
303 do_settings_fields( $page, $section['id'] );
304 echo '</table>';
305 if ( $section_count > 1 ) {
306 echo '</div>';
307 }
308 }
309 }
310 }
311
312 if ( ! function_exists( 'wc_rbp_get_form_hidden_fields' ) ) {
313 /**
314 * Returns Required WC RBP hidden Fields
315 */
316
317 function wc_rbp_get_form_hidden_fields( $action, $wp_nounce_name, $referer = true ) {
318 $return = '<input type="hidden" name="wcrbp-action" value="' . $action . '" />';
319 $return .= wp_nonce_field( $action, $wp_nounce_name, $referer, false );
320 return $return;
321 }
322 }
323
324 if ( ! function_exists( 'wc_rbp_get_editor_fields' ) ) {
325 function wc_rbp_get_editor_fields( $type ) {
326 $fields = wc_rbp_get_form_hidden_fields( 'wc_rbp_save_product_prices', 'wc_rbp_nounce' );
327 $fields .= '<input type="hidden" name="type" value="' . $type . '" />';
328 return $fields;
329 }
330 }
331
332 if ( ! function_exists( 'wc_rbp_get_ajax_overlay' ) ) {
333 /**
334 * Prints WC RBP Ajax Loading Code
335 */
336 function wc_rbp_get_ajax_overlay( $echo = true ) {
337 $return = '<div class="wc_rbp_ajax_overlay">
338 <div class="sk-folding-cube">
339 <div class="sk-cube1 sk-cube"></div>
340 <div class="sk-cube2 sk-cube"></div>
341 <div class="sk-cube4 sk-cube"></div>
342 <div class="sk-cube3 sk-cube"></div>
343 </div>
344 </div>';
345 if ( $echo ) {
346 echo $return;
347 } else {
348 return $return;
349 }
350 }
351 }
352
353 if ( ! function_exists( 'wc_rbp_check_active_addon' ) ) {
354 function wc_rbp_check_active_addon( $slug ) {
355 $addons = wc_rbp_get_active_addons();
356 if ( in_array( $slug, $addons ) ) {
357 return true;
358 }
359 return false;
360 }
361 }
362
363 if ( ! function_exists( 'wc_rbp_get_active_addons' ) ) {
364 /**
365 * Returns Active Addons List
366 *
367 * @return [[Type]] [[Description]]
368 */
369 function wc_rbp_get_active_addons() {
370 $addons = get_option( WC_RBP_DB . 'active_addons', array() );
371 return $addons;
372 }
373 }
374
375 if ( ! function_exists( 'wc_rbp_update_active_addons' ) ) {
376 /**
377 * Returns Active Addons List
378 *
379 * @return [[Type]] [[Description]]
380 */
381 function wc_rbp_update_active_addons( $addons ) {
382 update_option( WC_RBP_DB . 'active_addons', $addons );
383 return true;
384 }
385 }
386
387 if ( ! function_exists( 'wc_rbp_activate_addon' ) ) {
388 function wc_rbp_activate_addon( $slug ) {
389 $active_list = wc_rbp_get_active_addons();
390 if ( ! in_array( $slug, $active_list ) ) {
391 $active_list[] = $slug;
392 wc_rbp_update_active_addons( $active_list );
393 return true;
394 }
395 return false;
396 }
397 }
398
399 if ( ! function_exists( 'wc_rbp_deactivate_addon' ) ) {
400 function wc_rbp_deactivate_addon( $slug ) {
401 $active_list = wc_rbp_get_active_addons();
402 if ( in_array( $slug, $active_list ) ) {
403 $key = array_search( $slug, $active_list );
404 unset( $active_list[ $key ] );
405 wc_rbp_update_active_addons( $active_list );
406 return true;
407 }
408 return false;
409 }
410 }
411
412 if ( ! function_exists( 'wc_rbp_admin_notice' ) ) {
413 function wc_rbp_admin_notice( $msg, $type = 'updated' ) {
414 $notice = ' <div class="' . $type . ' settings-error notice is-dismissible" id="setting-error-settings_updated">
415 <p>' . $msg . '</p><button class="notice-dismiss" type="button"><span class="screen-reader-text">Dismiss this notice.</span></button></div>';
416 return $notice;
417 }
418 }
419
420 if ( ! function_exists( 'wc_rbp_generate_tabs' ) ) {
421 function wc_rbp_generate_tabs( $tabs, $content, $args = array() ) {
422 $default_args = array(
423 'show_image' => true,
424 'tab_style' => 'left', // 'default', 'box' or 'left'. Optional
425 'tab_wrapper' => true,
426
427 );
428
429
430 $args = wp_parse_args( $args, $default_args );
431 $wraper_start = '<div class="wcrbp-tabs wcrbp-tabs-' . $args['tab_style'] . '">';
432 $wraper_end = '</div>';
433
434 $tabs_code = '<ul class="wcrbp-tab-nav">';
435 $i = 0;
436 foreach ( $tabs as $key => $tab_data ) {
437 if ( is_string( $tab_data ) ) {
438 $tab_data = array( 'title' => $tab_data );
439 }
440 $tab_data = wp_parse_args( $tab_data, array( 'icon' => '', 'title' => '', 'show_status' => true ) );
441 if ( filter_var( $tab_data['icon'], FILTER_VALIDATE_URL ) ) {
442 $icon = '<img src="' . $tab_data['icon'] . '">';
443 } else {
444 if ( false !== strpos( $tab_data['icon'], 'dashicons' ) ) {
445 $tab_data['icon'] .= ' dashicons';
446 }
447 $tab_data['icon'] = array_filter( array_map( 'trim', explode( ' ', $tab_data['icon'] ) ) );
448 $tab_data['icon'] = implode( ' ', array_unique( $tab_data['icon'] ) );
449 $icon = $tab_data['icon'] ? '<i class="' . $tab_data['icon'] . '"></i>' : '';
450 }
451
452 $show_status = 'no';
453 $status_tag = '';
454 if ( $tab_data['show_status'] ) {
455 $show_status = 'yes';
456 $status_tag = '<i class="wc-rbp-tab-status"></i>';
457 }
458
459 $class = "wcrbp-tab-$key";
460 if ( ! $i ) {
461 $class .= ' wcrbp-tab-active';
462 }
463 $tabs_code .= sprintf( '<li data-status="%s" class="%s" data-panel="%s"><a href="#">%s%s%s</a></li>', $show_status, $class, $key, $icon, $tab_data['title'], $status_tag );
464 $i++;
465 }
466
467 $tabs_code .= '</ul>';
468
469
470 $content_data = '<div class="wcrbp-tab-panels">';
471 foreach ( $content as $id => $data ) {
472 $content_data .= '<div class="wcrbp-tab-panel wcrbp-tab-panel-' . $id . '">';
473 $content_data .= $data;
474 $content_data .= '</div>';
475 }
476
477 $content_data .= '</div>';
478
479 $final = $wraper_start . $tabs_code . $content_data . $wraper_end;
480 return $final;
481 }
482 }
483
484 if ( ! function_exists( 'wc_rbp_allowed_roles' ) ) {
485
486 function wc_rbp_allowed_roles() {
487 $roles = wc_rbp_option( 'allowed_roles' );
488 if ( empty( $roles ) ) {
489 $roles = array_keys( wc_rbp_get_user_roles_selectbox() );
490 }
491
492 return $roles;
493 }
494 }
495
496 if ( ! function_exists( 'wc_rbp_allowed_price' ) ) {
497
498 function wc_rbp_allowed_price() {
499 $roles = wc_rbp_option( 'allowed_price' );
500 if ( empty( $roles ) ) {
501 $roles = array_keys( wc_rbp_avaiable_price_type() );
502 }
503
504 return $roles;
505 }
506 }
507
508 /** @public Below Function Are Used By The Plugin users */
509
510 if ( ! function_exists( 'wc_rbp_update_role_based_price' ) ) {
511 /**
512 * Updates Products Role Based Price Array In DB
513 *
514 * @param int $post_id Post ID To Update
515 * @param array $price_array Price List
516 *
517 * @return boolean [[Description]]
518 */
519 function wc_rbp_update_role_based_price( $post_id, $price_array, $force_update_parent = true ) {
520 update_post_meta( $post_id, '_role_based_price', $price_array );
521 if ( $force_update_parent ) {
522 $parent = wp_get_post_parent_id( $post_id );
523 if ( $parent !== false ) {
524 wc_rbp_update_variations_data( $parent );
525 }
526 }
527 return true;
528 }
529 }
530
531 if ( ! function_exists( 'wc_rbp_get_variation_cache_key' ) ) {
532 function wc_rbp_get_variation_cache_key( $product_id = '', $user_role = '' ) {
533 return '_wcrbp_p_' . $product_id . '_' . $user_role;
534 }
535 }
536
537 if ( ! function_exists( 'wc_rbp_delete_variation_data' ) ) {
538 function wc_rbp_delete_variation_data( $product_id = '', $user_role = '' ) {
539 $old_cache_array = array(
540 '_wcrbp_p_' . $product_id . '_' . $user_role,
541 'wcrbp_p_' . $product_id . '_' . $user_role,
542 wc_rbp_get_variation_cache_key( $product_id, $user_role ),
543 );
544 foreach ( $old_cache_array as $key ) {
545 delete_transient( $key );
546 }
547 }
548 }
549
550 if ( ! function_exists( 'wc_rbp_get_variation_data' ) ) {
551 function wc_rbp_get_variation_data( $product_id = '', $user_role = '' ) {
552 $key = wc_rbp_get_variation_cache_key( $product_id, $user_role );
553 $prices = get_transient( $key );
554
555 if ( is_array( $prices ) && isset( $prices['wc_rbp_version'] ) ) {
556 if ( WC_RBP_VARIABLE_VERSION == $prices['wc_rbp_version'] ) {
557 return $prices;
558 }
559 }
560
561 if ( ! is_array( $prices ) && ! isset( $prices['wc_rbp_version'] ) ) {
562 wc_rbp_delete_variation_data( $product_id, $user_role );
563 }
564 wc_rbp_update_variations_data( $product_id, array( $user_role ) );
565 $prices = get_transient( $key );
566 return ( empty( $prices ) ) ? array() : $prices;
567 }
568 }
569
570 if ( ! function_exists( "wc_rbp_update_variations_data" ) ) {
571 function wc_rbp_update_variations_data( $pid, $role = array(), $aprice = array() ) {
572 if ( empty( $role ) || ! is_array( $role ) ) {
573 $allowed_roles = array_keys( wc_rbp_get_user_roles_selectbox() );
574 } else {
575 $allowed_roles = $role;
576 }
577
578 $allowed_price = array_keys( wc_rbp_avaiable_price_type() );
579
580 $product = wc_get_product( $pid );
581 if ( ! $product ) {
582 return;
583 }
584 $pricing = new WooCommerce_Role_Based_Price_Product_Pricing( false );
585
586 foreach ( $allowed_roles as $_role ) {
587 $cache_key = wc_rbp_get_variation_cache_key( $pid, $_role );
588 $prices = array(
589 'base_selling_price' => array(),
590 'base_regular_price' => array(),
591 'last_updated' => time(),
592 'wc_rbp_version' => WC_RBP_VARIABLE_VERSION,
593 );
594 foreach ( $allowed_price as $A_price ) {
595 foreach ( $product->get_children() as $vid ) {
596 $price = get_post_meta( $vid, '_regular_price', true );
597 if ( $A_price == 'selling_price' ) {
598 $price = get_post_meta( $vid, '_sale_price', true );
599 }
600 $prices[ 'base_' . $A_price ][ $vid ] = $price;
601 $pprice = $pricing->get_product_price( $price, $vid, $A_price, $_role );
602 if ( $pprice === '' ) {
603 continue;
604 }
605
606 $prices[ $A_price ][ $vid ] = $pprice;
607 }
608 }
609
610 set_transient( $cache_key, $prices, 240 * HOUR_IN_SECONDS );
611 }
612 }
613 }
614
615 if ( ! function_exists( 'wc_rbp_get_product_price' ) ) {
616
617 /**
618 * Gets Product price from DB
619 * #TODO Integrate Wth product_rbp_price function to make it faster
620 */
621 function wc_rbp_get_product_price( $post_id, $supress_filter = false ) {
622 $price = get_post_meta( $post_id, '_role_based_price' );
623
624 if ( ! empty( $price ) ) {
625 $price = $price[0];
626 } else {
627 $price = array();
628 }
629 if ( ! $supress_filter )
630 $price = apply_filters( 'wc_rbp_product_prices', $price );
631 return $price;
632 }
633
634 }
635
636 if ( ! function_exists( 'wc_rbp_product_get_db' ) ) {
637 function wc_rbp_product_get_db( $post_id, $type = 'price', $function = '' ) {
638 global $wc_rbp_db_array;
639
640 $return_val = $function( $post_id );
641 $wc_rbp_db_array[ $post_id ][ $type ] = $return_val;
642 $return_val = $wc_rbp_db_array[ $post_id ][ $type ];
643 return $return_val;
644 }
645 }
646
647 if ( ! function_exists( "wc_rbp_product_variable" ) ) {
648 function wc_rbp_product_variable( $post_id, $type = 'price', $function = '' ) {
649 if ( $type == 'price' ) {
650 $function = 'wc_rbp_get_product_price';
651 } elseif ( $type == 'status' ) {
652 $function = 'wc_rbp_product_status';
653 }
654 return wc_rbp_product_get_db( $post_id, $type, $function );
655 }
656 }
657
658 if ( ! function_exists( 'product_rbp_price' ) ) {
659 /**
660 * Gets product price from DB
661 */
662 function product_rbp_price( $post_id ) {
663 $price = wc_rbp_product_variable( $post_id, 'price' );
664 $price = apply_filters( "product_rbp_price", $price, $post_id );
665 return $price;
666 }
667 }
668
669 if ( ! function_exists( 'product_rbp_status' ) ) {
670 /**
671 * Returns Products Role Based Price Array In DB
672 *
673 * @param int $post_id Post ID To Update
674 * @param array $price_array Price List
675 *
676 * @return boolean [[Description]]
677 * #TODO Integrate WC_RBP_PRODUCT_STATUS Function For Speed Outpu
678 */
679 function product_rbp_status( $post_id ) {
680 global $product;
681 $price = wc_rbp_product_variable( $post_id, 'status' );
682 $price = apply_filters( "product_rbp_status", $price, $post_id );
683 return $price;
684 }
685 }
686
687 if ( ! function_exists( 'wc_rbp_settings_products_json' ) ) {
688 function wc_rbp_settings_products_json( $ids ) {
689 $json_ids = array();
690 if ( ! empty( $ids ) ) {
691 if ( is_string( $ids ) ) {
692 $ids = explode( ',', $ids );
693 }
694
695 foreach ( $ids as $product_id ) {
696 $product = wc_get_product( $product_id );
697 if ( $product ) {
698 $json_ids[ $product_id ] = wp_kses_post( $product->get_formatted_name() );
699 }
700 }
701 }
702 return $json_ids;
703 }
704 }
705
706 if ( ! function_exists( 'wc_rbp_update_role_based_price_status' ) ) {
707
708 /**
709 * Updates Products Role Based Price Array In DB
710 *
711 * @param int $post_id Post ID To Update
712 * @param array $price_array Price List
713 *
714 * @return boolean [[Description]]
715 */
716 function wc_rbp_update_role_based_price_status( $post_id, $status = true ) {
717 update_post_meta( $post_id, '_enable_role_based_price', $status );
718 return true;
719 }
720 }
721
722 if ( ! function_exists( 'wc_rbp_product_status' ) ) {
723 /**
724 * Retrives Status value from Databse.
725 *
726 * @param [[Type]] $post_id [[Description]]
727 *
728 * @return [[Type]] [[Description]]
729 * #TODO Integrate With product_rbp_status
730 */
731 function wc_rbp_product_status( $post_id, $supress_filter = false ) {
732 $cstatus = false;
733 $status = get_post_meta( $post_id, '_enable_role_based_price', true );
734 if ( $status == '1' || $status == 'true' ) {
735 $cstatus = true;
736 }
737
738 if ( ! $supress_filter )
739 $cstatus = apply_filters( 'wc_rbp_product_status', $cstatus, $post_id );
740
741 return $cstatus;
742 }
743 }
744
745 if ( ! function_exists( 'wc_rbp_price' ) ) {
746 /**
747 * Returns Price Based On Give Value
748 *
749 * @role : enter role slug / use all to get all roles values
750 * @price : use selling_price / regular_price or use all to get all values for the given role
751 */
752
753 function wc_rbp_price( $post_id, $role, $price = 'regular_price', $args = array() ) {
754 $dbprice = product_rbp_price( $post_id );
755 $return = false;
756
757 if ( $price == 'all' && $role == 'all' ) {
758 $return = $dbprice;
759 } elseif ( $price == 'all' && $role !== 'all' ) {
760 if ( isset( $dbprice[ $role ] ) ) {
761 $return = $dbprice[ $role ];
762 }
763 } elseif ( isset( $dbprice[ $role ][ $price ] ) ) {
764 $return = $dbprice[ $role ][ $price ];
765 }
766
767 $return = apply_filters( 'wc_rbp_product_price', $return, $role, $price, $post_id, $args );
768 return $return;
769 }
770 }
771
772 if ( ! function_exists( 'wc_rbp_active_price' ) ) {
773
774 function wc_rbp_active_price( $post_id, $role, $args = array(), $product = null ) {
775 $price = wc_rbp_price( $post_id, $role, 'all', $args );
776 if ( isset( $price['selling_price'] ) ) {
777 if ( ! empty( $price['selling_price'] ) ) {
778 return $price['selling_price'];
779 }
780 }
781
782 return $price['regular_price'];
783 }
784 }
785
786 if ( ! function_exists( 'wc_rbp_sort_array_by_array' ) ) {
787 function wc_rbp_sort_array_by_array( array $array, array $orderArray ) {
788 $ordered = array();
789 foreach ( $orderArray as $key ) {
790 if ( array_key_exists( $key, $array ) ) {
791 $ordered[ $key ] = $array[ $key ];
792 unset( $array[ $key ] );
793 }
794 }
795 return $ordered + $array;
796 }
797 }
798
799 if ( ! function_exists( 'wc_rbp_remove_notice' ) ) {
800 function wc_rbp_remove_notice( $id ) {
801 WooCommerce_Plugin_Boiler_Plate_Admin_Notices::getInstance()
802 ->deleteNotice( $id );
803 return true;
804 }
805 }
806
807 if ( ! function_exists( 'wc_rbp_notice' ) ) {
808 function wc_rbp_notice( $message, $type = 'update', $args = array() ) {
809 $notice = '';
810 $defaults = array( 'times' => 1, 'screen' => array(), 'users' => array(), 'wraper' => true, 'id' => '' );
811 $args = wp_parse_args( $args, $defaults );
812 extract( $args );
813
814 if ( $type == 'error' ) {
815 $notice = new WooCommerce_Role_Based_Price_Admin_Error_Notice( $message, $id, $times, $screen, $users );
816 }
817
818 if ( $type == 'update' ) {
819 $notice = new WooCommerce_Role_Based_Price_Admin_Updated_Notice( $message, $id, $times, $screen, $users );
820 }
821
822 if ( $type == 'upgrade' ) {
823 $notice = new WooCommerce_Role_Based_Price_Admin_UpdateNag_Notice( $message, $id, $times, $screen, $users );
824 }
825
826 $msgID = $notice->getId();
827 $message = str_replace( '$msgID$', $msgID, $message );
828 $notice->setContent( $message );
829 $notice->setWrapper( $wraper );
830 WooCommerce_Role_Based_Price_Admin_Notices::getInstance()
831 ->addNotice( $notice );
832 }
833 }
834
835 if ( ! function_exists( 'wc_rbp_admin_error' ) ) {
836 function wc_rbp_admin_error( $message, $times = 1, $id, $screen = array(), $args = array() ) {
837 $args['id'] = $id;
838 $args['times'] = $times;
839 $args['screen'] = $screen;
840 wc_rbp_notice( $message, 'error', $args );
841 }
842 }
843
844 if ( ! function_exists( 'wc_rbp_admin_update' ) ) {
845 function wc_rbp_admin_update( $message, $times = 1, $id, $screen = array(), $args = array() ) {
846 $args['id'] = $id;
847 $args['times'] = $times;
848 $args['screen'] = $screen;
849 wc_rbp_notice( $message, 'update', $args );
850 }
851 }
852
853 if ( ! function_exists( 'wc_rbp_admin_upgrade' ) ) {
854 function wc_rbp_admin_upgrade( $message, $times = 1, $id, $screen = array(), $args = array() ) {
855 $args['id'] = $id;
856 $args['times'] = $times;
857 $args['screen'] = $screen;
858 wc_rbp_notice( $message, 'upgrade', $args );
859 }
860 }
861
862 if ( ! function_exists( 'wc_rbp_remove_link' ) ) {
863 function wc_rbp_remove_link( $attributes = '', $msgID = '$msgID$', $text = 'Remove Notice' ) {
864 if ( ! empty( $msgID ) ) {
865 $removeKey = PLUGIN_DB . 'MSG';
866 $url = admin_url() . '?' . $removeKey . '=' . $msgID;
867 //$url = wp_nonce_url($url, 'WCQDREMOVEMSG');
868 $url = urldecode( $url );
869 $tag = '<a ' . $attributes . ' href="' . $url . '">' . __( $text, WC_RBP_TXT ) . '</a>';
870 return $tag;
871 }
872 }
873 }
874
875 if ( ! function_exists( 'wc_rbp_is_wc_v' ) ) {
876 function wc_rbp_is_wc_v( $compare = '>=', $version = '3.0' ) {
877 $version = empty( $version ) ? WOOCOMMERCE_VERSION : $version;
878 if ( version_compare( WOOCOMMERCE_VERSION, $version, $compare ) ) {
879 return true;
880 } else {
881 return false;
882 }
883 }
884 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 /**
4 * Fired during plugin activation.
5 *
6 * This class defines all code necessary to run during the plugin's activation.
7 *
8 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
9 * @package Role Based Price For WooCommerce
10 * @subpackage Role Based Price For WooCommerce/core
11 * @since 3.0
12 */
13 class WooCommerce_Role_Based_Price_Activator {
14
15 public function __construct() {
16 }
17
18 /**
19 * Short Description. (use period)
20 *
21 * Long Description.
22 *
23 * @since 1.0.0
24 */
25 public static function activate() {
26 require_once( WC_RBP_INC . 'helpers/class-version-check.php' );
27 require_once( WC_RBP_INC . 'helpers/class-dependencies.php' );
28
29 if( WooCommerce_Role_Based_Price_Dependencies(WC_RBP_DEPEN) ) {
30 WooCommerce_Role_Based_Price_Version_Check::activation_check('3.7');
31
32 $message = '<h3> <center> ' . __("Thank you for installing <strong>Role Based Price For WooCommerce</strong> : <strong>Version 3.0 </strong>", WC_RBP_TXT) . '</center> </h3>';
33 $message .= '<p>' . __("We have worked entire 1 year to improve our plugin to best of our ability and we hope you will enjoy working with it. We are always open for your sugestions and feature requests", WC_RBP_TXT) . '</p>';
34
35 $message .= '</hr>';
36 $message .= '<p>' . __("If you have installed <strong>WPRB</strong> for the 1st time or upgrading from <strong> Version 2.8.7</strong> then you will need to update its' settings once again or this plugin will not function properly. ", WC_RBP_TXT);
37
38 $url = admin_url('admin.php?page=woocommerce-role-based-price-settings');
39 $message .= '<a href="' . $url . '" class="button button-primary">' . __("Click Here to update the settings", WC_RBP_TXT) . '</a> </p>';
40
41 wc_rbp_admin_update($message, 1, 'activate_message', array(), array( 'wraper' => FALSE, 'times' => 1 ));
42
43 set_transient('_welcome_redirect_wcrbp', TRUE, 60);
44
45 } else {
46 if( is_plugin_active(WC_RBP_FILE) ) {
47 deactivate_plugins(WC_RBP_FILE);
48 }
49 wp_die(wc_rbp_dependency_message());
50 }
51 }
52
53 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 class WooCommerce_Role_Based_Price_Admin_Notices {
4
5 protected static $instance;
6 protected $noticesArrayName;
7 protected $REQUESTID;
8 protected $notices;
9
10 /**
11 * Costructor (private since this is a singleton)
12 */
13 private function __construct() {
14 self::$instance = NULL;
15 $this->noticesArrayName = WC_RBP_DB . 'AdminNotices';
16 $this->REQUESTID = WC_RBP_DB . 'MSG';
17 $this->notices = array();
18 $this->loadNotices();
19 $this->auto_remove_Notice();
20 add_action('admin_notices', array( $this, 'displayNotices' ));
21 }
22
23 /**
24 * Loads notices from DB
25 */
26 private function loadNotices() {
27 $notices = get_option($this->noticesArrayName);
28 if( is_array($notices) ) {
29 $this->notices = $notices;
30 }
31 }
32
33 /**
34 * Removes Notice By Getting ID From GET / POST METHOD
35 */
36 public function auto_remove_Notice() {
37
38 if( isset($_REQUEST[$this->REQUESTID]) ) {
39 $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
40 $this->deleteNotice(sanitize_text_field($_REQUEST[$this->REQUESTID]));
41 if( wp_get_referer() ) {
42 wp_safe_redirect(wp_get_referer());
43 }
44 }
45 }
46
47 /**
48 * Deletes a notice
49 *
50 * @param int $notId The notice unique id
51 */
52 public function deleteNotice($notId) {
53 foreach( $this->notices as $key => $notice ) {
54 if( $notice->getId() === $notId ) {
55 unset($this->notices[$key]);
56 break;
57 }
58 }
59 $this->storeNotices();
60 }
61
62 /**
63 * Stores notices in DB
64 */
65 private function storeNotices() {
66 update_option($this->noticesArrayName, $this->notices);
67 }
68
69 /**
70 * Returns an instance of this class.
71 *
72 * @since 1.0.0
73 * @return WP_Admin_Notices
74 */
75 public static function getInstance() {
76 if( NULL == self::$instance ) {
77 self::$instance = new self();
78 }
79 return self::$instance;
80 }
81
82 /**
83 * Action hook to display notices.
84 * Just echoes notices that should be displayed.
85 */
86 public function displayNotices() {
87 foreach( $this->notices as $key => $notice ) {
88 if( $this->isTimeToDisplay($notice) ) {
89 echo $notice->getContentFormated($notice->getWrapper());
90 $notice->incrementDisplayedTimes();
91 }
92 if( $notice->getTimes() > 0 ) {
93 if( $notice->isTimeToDie() ) {
94 unset($this->notices[$key]);
95 }
96 }
97
98 }
99 $this->storeNotices();
100 }
101
102 /**
103 * Checks if is time to display a notice
104 *
105 * @param WooCommerce_Role_Based_Price_Admin_Notice $notice
106 *
107 * @return bool
108 */
109 private function isTimeToDisplay(WooCommerce_Role_Based_Price_Admin_Notice $notice) {
110 $screens = $notice->getScreen();
111 if( ! empty($screens) ) {
112 $curScreen = get_current_screen();
113 if( ! is_array($screens) || ! in_array($curScreen->id, $screens) ) {
114 return FALSE;
115 }
116 }
117
118 $usersArray = $notice->getUsers();
119 if( ! empty($usersArray) ) {
120 $curUser = get_current_user_id();
121 if( ! is_array($usersArray) || ! in_array($curUser, $usersArray) || $usersArray[$curUser] >= $notice->getTimes() ) {
122 return FALSE;
123 }
124
125
126 } else if( $notice->getTimes() == 0 ) {
127 return TRUE;
128 } else if( $notice->getTimes() <= $notice->getDisplayedTimes() ) {
129 return FALSE;
130 }
131
132 return TRUE;
133 }
134
135 /**
136 * Adds a notice to be displayed
137 *
138 * @param erpAdminMessage $notice
139 */
140 public function addNotice(WooCommerce_Role_Based_Price_Admin_Notice $notice) {
141 $this->notices[] = $notice;
142 $this->storeNotices();
143 }
144
145 }
146
147 /**
148 * Abstract class of a notice
149 *
150 * @author Panagiotis Vagenas <pan.vagenas@gmail.com>
151 */
152 abstract class WooCommerce_Role_Based_Price_Admin_Notice {
153 protected $content;
154 protected $type;
155 protected $screen;
156 protected $id;
157 protected $times = 1;
158 protected $users = array();
159 protected $displayedTimes = 0;
160 protected $displayedToUsers = array();
161 protected $WithWraper = TRUE;
162 protected $is_dismissible = TRUE;
163
164 /**
165 *
166 * @param type $content Coantent to be displayed
167 * @param type $times How many times this notice will be displayed
168 * @param array $screen The admin screens this notice will be displayed into (empty for all screens)
169 * @param array $users Array of users this notice concernes (empty for all users)
170 */
171 public function __construct($content, $id = '', $times = 1, $screen = array(), $users = array(), $WithWraper = TRUE) {
172 $this->content = $content;
173 $this->screen = $screen;
174 if( empty($id) ) {
175 $this->id = uniqid();
176 } else {
177 $this->id = $id;
178 }
179 $this->times = $times;
180 $this->users = $users;
181 $this->WithWraper = $WithWraper;
182 }
183
184 /**
185 * Get the content of the notice
186 *
187 * @param bool $wrapInParTag If the content should be wrapped in a paragraph tag
188 *
189 * @return string Formated content
190 */
191 public function getContentFormated($wrapInParTag = TRUE) {
192 $class = $this->type;
193 $extrC = '';
194
195 if( $this->is_dismissible ) {
196 $class .= ' notice is-dismissible';
197 }
198
199
200 $before = '<div id="wc_pbp_notice_' . $this->id . '" class="' . $class . '">';
201 $before .= $wrapInParTag ? '<p>' : '';
202 $after = $wrapInParTag ? '</p>' : '';
203 $after .= '</div>';
204 return $before . $this->getContent() . $after . $extrC;
205 }
206
207 /**
208 * Get the notice string unformated
209 *
210 * @return string
211 */
212 public function getContent() {
213 return $this->content;
214 }
215
216 /**
217 *
218 * @param string $content
219 *
220 * @return \WooCommerce_Role_Based_Price_Admin_Notice
221 */
222 public function setContent($content) {
223 $this->content = $content;
224 return $this;
225 }
226
227 /**
228 * Increment displayed times of the notice
229 *
230 * @return \WooCommerce_Role_Based_Price_Admin_Notice
231 */
232 public function incrementDisplayedTimes() {
233 $this->displayedTimes++;
234
235 if( array_key_exists(get_current_user_id(), $this->displayedToUsers) ) {
236 $this->displayedToUsers[get_current_user_id()]++;
237 } else {
238 $this->displayedToUsers[get_current_user_id()] = 1;
239 }
240 return $this;
241 }
242
243 /**
244 * Checks if the notice should me destroyed
245 *
246 * @return boolean True iff notice is deprecated
247 */
248 public function isTimeToDie() {
249 if( empty($this->users) ) {
250 return $this->displayedTimes >= $this->times;
251 } else {
252 $i = 0;
253 foreach( $this->users as $key => $value ) {
254 if( isset($this->displayedToUsers[$value]) && $this->displayedToUsers[$value] >= $this->times ) {
255 $i++;
256 }
257 }
258 if( $i >= count($this->users) ) {
259 return TRUE;
260 }
261 }
262 return FALSE;
263 }
264
265 /**
266 * Get the $WithWraper Value
267 */
268 public function getWrapper() {
269 return $this->WithWraper;
270 }
271
272 /**
273 * Set the $WithWraper Value
274 *
275 * @param boolean $screen
276 */
277 public function setWrapper($wrapper = TRUE) {
278 $this->WithWraper = $wrapper;
279 return $this;
280 }
281
282 /**
283 * Get the current screen slug
284 *
285 * @return string Current screen slug
286 */
287 public function getScreen() {
288 return $this->screen;
289 }
290
291 /**
292 * Set the screens the notice will be displayed
293 *
294 * @param array $screen
295 *
296 * @return \WooCommerce_Role_Based_Price_Admin_Notice
297 */
298 public function setScreen($screen) {
299 $this->screen = $screen;
300 return $this;
301 }
302
303 /**
304 *
305 * @return string
306 */
307 public function getId() {
308 return $this->id;
309 }
310
311 /**
312 *
313 * @return int
314 */
315 public function getTimes() {
316 return $this->times;
317 }
318
319 /**
320 *
321 * @param int $times
322 *
323 * @return \WooCommerce_Role_Based_Price_Admin_Notice
324 */
325 public function setTimes($times) {
326 $this->times = $times;
327 return $this;
328 }
329
330 /**
331 *
332 * @return array
333 */
334 public function getUsers() {
335 return $this->users;
336 }
337
338 /**
339 *
340 * @param array $users
341 *
342 * @return \WooCommerce_Role_Based_Price_Admin_Notice
343 */
344 public function setUsers(Array $users) {
345 $this->users = $users;
346 return $this;
347 }
348
349 /**
350 *
351 * @return int
352 */
353 public function getDisplayedTimes() {
354 return $this->displayedTimes;
355 }
356
357 /**
358 *
359 * @param int $displayedTimes
360 *
361 * @return \WooCommerce_Role_Based_Price_Admin_Notice
362 */
363 public function setDisplayedTimes($displayedTimes) {
364 $this->displayedTimes = $displayedTimes;
365 return $this;
366 }
367
368 /**
369 *
370 * @return array
371 */
372 public function getDisplayedToUsers() {
373 return $this->displayedToUsers;
374 }
375
376 /**
377 *
378 * @param array $displayedToUsers
379 *
380 * @return \WooCommerce_Role_Based_Price_Admin_Notice
381 */
382 public function setDisplayedToUsers(Array $displayedToUsers) {
383 $this->displayedToUsers = $displayedToUsers;
384 return $this;
385 }
386
387 }
388
389 /**
390 * Type of notices
391 */
392 class WooCommerce_Role_Based_Price_Admin_Error_Notice extends WooCommerce_Role_Based_Price_Admin_Notice {
393 protected $type = 'error';
394 }
395
396 class WooCommerce_Role_Based_Price_Admin_Updated_Notice extends WooCommerce_Role_Based_Price_Admin_Notice {
397 protected $type = 'updated';
398 }
399
400 class WooCommerce_Role_Based_Price_Admin_UpdateNag_Notice extends WooCommerce_Role_Based_Price_Admin_Notice {
401 protected $type = 'update-nag';
402 }
403
404
405 /**
406 * Hook action to admin init
407 */
408 if( ! has_action('init', array( 'WooCommerce_Role_Based_Price_Admin_Notices', 'getInstance' )) ) {
409 add_action('init', array( 'WooCommerce_Role_Based_Price_Admin_Notices', 'getInstance' ));
410 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 /**
4 * Fired during plugin deactivation.
5 *
6 * This class defines all code necessary to run during the plugin's deactivation.
7 *
8 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
9 * @package Role Based Price For WooCommerce
10 * @subpackage Role Based Price For WooCommerce/core
11 * @since 3.0
12 */
13 class WooCommerce_Role_Based_Price_Deactivator {
14 /**
15 * Short Description. (use period)
16 *
17 * Long Description.
18 *
19 * @since 1.0.0
20 */
21 public static function deactivate() {
22
23 }
24
25 public static function dependency_deactivate() {
26 if( is_plugin_active(WC_RBP_FILE) ) {
27 add_action('update_option_active_plugins', array( __CLASS__, 'deactivate_dependent' ));
28 }
29 }
30
31 public static function deactivate_dependent() {
32 delete_transient('_welcome_redirect_wcrbp');
33 deactivate_plugins(WC_RBP_FILE);
34 }
35
36 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Dependency Checker
4 *
5 * Checks if required Dependency plugin is enabled
6 *
7 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
8 * @package Role Based Price For WooCommerce
9 * @subpackage Role Based Price For WooCommerce/core
10 * @since 3.0
11 */
12
13 if( ! class_exists('WooCommerce_Role_Based_Price_Dependencies') ) {
14 class WooCommerce_Role_Based_Price_Dependencies {
15
16 private static $active_plugins;
17
18 public static function init() {
19 self::$active_plugins = (array) get_option('active_plugins', array());
20 if( is_multisite() )
21 self::$active_plugins = array_merge(self::$active_plugins, get_site_option('active_sitewide_plugins', array()));
22 }
23
24 public static function active_check($pluginToCheck = '') {
25 if( ! self::$active_plugins )
26 self::init();
27 return in_array($pluginToCheck, self::$active_plugins) || array_key_exists($pluginToCheck, self::$active_plugins);
28 }
29 }
30 }
31 /**
32 * WC Detection
33 */
34 if( ! function_exists('WooCommerce_Role_Based_Price_Dependencies') ) {
35 function WooCommerce_Role_Based_Price_Dependencies($pluginToCheck = 'woocommerce/woocommerce.php') {
36 return WooCommerce_Role_Based_Price_Dependencies::active_check($pluginToCheck);
37 }
38 }
39 ?>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 /**
4 * Check the version of WordPress
5 *
6 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
7 * @package Role Based Price For WooCommerce
8 * @subpackage Role Based Price For WooCommerce/core
9 * @since 3.0
10 */
11 class WooCommerce_Role_Based_Price_Version_Check {
12 static $version;
13
14 /**
15 * The primary sanity check, automatically disable the plugin on activation if it doesn't meet minimum requirements
16 *
17 * @since 1.0.0
18 */
19 public static function activation_check($version) {
20 self::$version = $version;
21 if( ! self::compatible_version() ) {
22 deactivate_plugins(WC_RBP_FILE);
23 wp_die(__(WC_RBP_NAME . ' requires WordPress ' . self::$version . ' or higher!', WC_RBP_TXT));
24 }
25 }
26
27 /**
28 * Check current version against $prefix_version_check
29 *
30 * @since 1.0.0
31 */
32 public static function compatible_version() {
33 if( version_compare($GLOBALS['wp_version'], self::$version, '<') ) {
34 return FALSE;
35 }
36 return TRUE;
37 }
38
39 /**
40 * The backup sanity check, in case the plugin is activated in a weird way, or the versions change after activation
41 *
42 * @since 1.0.0
43 */
44 public function check_version() {
45 if( ! self::compatible_version() ) {
46 if( is_plugin_active(WC_RBP_FILE) ) {
47 deactivate_plugins(WC_RBP_FILE);
48 add_action('admin_notices', array( $this, 'disabled_notice' ));
49 if( isset($_GET['activate']) ) {
50 unset($_GET['activate']);
51 }
52 }
53 }
54 }
55
56 /**
57 * Text to display in the notice
58 *
59 * @since 1.0.0
60 */
61 public function disabled_notice() {
62 echo '<strong>' . esc_html__(WC_RBP_NAME . ' requires WordPress ' . self::$version . ' or higher!', WC_RBP_TXT) . '</strong>';
63 }
64 }
...\ No newline at end of file ...\ No newline at end of file
1 ;
2 ( function( $, window, document ) {
3 'use strict';
4
5 $.WCRBP = $.WCRBP || {};
6
7
8 /**
9 * Global Functions
10 */
11 /* $.WCRBP.validate_selling_price = function (e) {
12 var sale_price_field = $(this),
13 regular_price_field;
14
15 regular_price_field = sale_price_field.parents('.wc_rbp_price_container').find('.wc_rbp_regular_price');
16
17 var sale_price = parseFloat(window.accounting.unformat(sale_price_field.val(), woocommerce_admin.mon_decimal_point));
18 var regular_price = parseFloat(window.accounting.unformat(regular_price_field.val(), woocommerce_admin.mon_decimal_point));
19
20
21 if ( sale_price >= regular_price ) {
22 $(document.body).triggerHandler('wc_add_error_tip', [$(this), 'i18_sale_less_than_regular_error']);
23 if ( 'change' === e.type ) {
24 if ( sale_price >= regular_price ) {
25 $(this).val('');
26 $('div#wc-rbp-product-editor #wc_rbp_update_price').removeAttr('disabled');
27 }
28 } else {
29 $('div#wc-rbp-product-editor #wc_rbp_update_price').attr('disabled', 'disabled');
30 }
31 } else {
32 $(document.body).triggerHandler('wc_remove_error_tip', [$(this), 'i18_sale_less_than_regular_error']);
33 $('div#wc-rbp-product-editor #wc_rbp_update_price').removeAttr('disabled');
34 }
35 };*/
36
37 $.WCRBP.tab_navigation = function( e ) {
38 e.preventDefault();
39
40 var $li = jQuery( this ).parent(),
41 panel = $li.data( 'panel' ),
42 $wrapper = $li.closest( '.wcrbp-tabs' ),
43 $panel = $wrapper.find( '.wcrbp-tab-panel-' + panel );
44
45 $li.addClass( 'wcrbp-tab-active' ).siblings().removeClass( 'wcrbp-tab-active' );
46 $panel.show().siblings().hide();
47 };
48
49 $.WCRBP.render_wootabs = function() {
50 $( ".wcrbp-tab-nav" ).on( "click", 'a', $.WCRBP.tab_navigation );
51
52 if( !$( '.wcrbp-tab-active' ).is( 'visible' ) ) {
53 var activePane = $( '.wcrbp-tab-panel[style*="block"]' ).index();
54
55 if( activePane >= 0 ) {
56 $( '.wcrbp-tab-nav li' ).removeClass( 'wcrbp-tab-active' );
57 $( '.wcrbp-tab-nav li' ).eq( activePane ).addClass( 'wcrbp-tab-active' );
58 }
59 }
60
61 $( '.wcrbp-tab-active a' ).trigger( 'click' );
62 $( '.wcrbp-tabs-no-wrapper' ).closest( '.postbox' ).addClass( 'wcrbp-tabs-no-controls' );
63
64
65 };
66
67 $.WCRBP.block = function( $elem ) {
68 $elem.block( {
69 message: null,
70 overlayCSS: {
71 background: '#fff',
72 opacity: 0.6
73 }
74 } );
75 };
76
77 $.WCRBP.unblock = function( $elem ) {
78 $elem.unblock();
79 };
80
81 $.WCRBP.render_price_status = function() {
82 $( '.wcrbp-tab-nav > li' ).each( function() {
83 if( $( this ).attr( 'data-status' ) == 'yes' ) {
84 var $this = $( this ),
85 divClass = 'div.wcrbp-tab-panel-' + $this.attr( 'data-panel' ),
86 filled = 0,
87 unfilled = 0,
88 totalf = 0;
89
90 $( divClass ).find( 'input[type=text]' ).each( function() {
91 if( $( this ).hasClass( "include_count" ) || !$( this ).hasClass( "exclude_count" ) ) {
92 if( $( this ).val() == '' ) {
93 unfilled = unfilled + 1;
94 } else {
95 filled = filled + 1;
96 }
97 }
98 } );
99
100 totalf = filled + unfilled;
101
102 $this.find( '.wc-rbp-tab-status' ).removeClass( 'bgred' );
103 $this.find( '.wc-rbp-tab-status' ).removeClass( 'bggreen' );
104 $this.find( '.wc-rbp-tab-status' ).removeClass( 'bgblue' );
105
106 if( filled == 0 && unfilled > 0 ) {
107 $this.find( '.wc-rbp-tab-status' ).addClass( 'bgred' );
108 } else if( filled > 0 && unfilled > 0 ) {
109 $this.find( '.wc-rbp-tab-status' ).addClass( 'bgblue' );
110 } else if( filled > 0 && unfilled == 0 ) {
111 $this.find( '.wc-rbp-tab-status' ).addClass( 'bggreen' );
112 }
113 }
114
115 } );
116 };
117
118 $.WCRBP.add_variation_selectbox = function() {
119 if( $( ".wcrbpvariationbx" ).size() > 0 ) {
120 $( ".wcrbpvariationbx" ).appendTo( "#wc-rbp-product-editor .hndle span" );
121 }
122
123 if( jQuery( '.wcrbpvariationbx' ).size() > 0 ) {
124 jQuery( '.wcrbpvariationbx' ).selectize( {
125 plugins: [ 'remove_button', 'restore_on_backspace' ],
126 persist: false,
127 create: false,
128 onChange: function( value ) {
129 $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) );
130 var $select = this;
131 var $parentID = $( 'input#post_ID' ).val();
132 $.ajax( {
133 url: ajaxurl + '?action=wc_rbp_metabox_refersh&pid=' + value + '&parentID=' + $parentID,
134 method: "GET",
135 data: '',
136 } ).done( function( response ) {
137 if( response.success === true ) {
138 $select.destroy();
139 $( '.wcrbpvariationbx' ).remove();
140 $( '#wc-rbp-product-editor .inside' ).html( response.data );
141 $.WCRBP.render_wootabs();
142 $.WCRBP.add_variation_selectbox();
143 $( "#wc-rbp-product-editor .inside input.wc_rbp_checkbox" ).wcrbp_checkbox();
144 $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) );
145 $.WCRBP.render_price_status();
146 }
147 } )
148 }
149 } );
150 }
151 };
152
153 $.WCRBP.move_selectbox_metabox = function() {
154 $( '#wc-rbp-product-editor' ).find( '.hndle' ).unbind( 'click' );
155
156 $( '#wc-rbp-product-editor' ).on( 'click', '.hndle', function( event ) {
157 event.preventDefault();
158 if( $( event.target ).filter( 'input, option, label, select, div, span' ).size() ) {
159 jQuery( '#wc-rbp-product-editor' ).toggleClass( 'closed' );
160 }
161
162 return;
163 } );
164 };
165
166 $.WCRBP.action_save_product_prices = function() {
167 var $clickedBtn = $( this ),
168 $data = $( 'div#wc-rbp-product-editor :input' ).serialize(),
169 $form = $( '.wc-rbp-metabox-container' ),
170 $action = $form.attr( 'action' ),
171 $method = $form.attr( 'method' );
172
173 $clickedBtn.attr( 'disabled', 'disable' );
174
175 $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) );
176
177 $.ajax( {
178 url: $action,
179 method: $method,
180 data: $data,
181 } ).done( function( data ) {
182 $clickedBtn.removeAttr( 'disabled' );
183 $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) );
184 $( 'div.wc_rbp_hidden_fields' ).html( data.data.hidden_fields );
185 $( 'div.wc_rbp_price_editor_ajax_response' ).html( data.data.html ).fadeIn( 'slow' );
186 setTimeout( 2000, function() {
187 jQuery( 'div.wc_rbp_price_editor_ajax_response' ).fadeOut( 'slow' );
188 } );
189 } )
190 };
191
192 $.WCRBP.action_clear_product_prices = function() {
193 var $clickedBtn = $( this );
194 $clickedBtn.attr( 'disabled', 'disable' );
195
196 $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) );
197
198 $.ajax( {
199 url: ajaxurl,
200 method: 'post',
201 data: { post_id: $( "#post_ID" ).val(), action: "wc_rbp_clear_variation_cache" }
202 } ).done( function( data ) {
203 $clickedBtn.removeAttr( 'disabled' );
204 $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) );
205 $( 'div.wc_rbp_price_editor_ajax_response' ).html( data.data.html ).fadeIn( 'slow' );
206 setTimeout( 2000, function() {
207 jQuery( 'div.wc_rbp_price_editor_ajax_response' ).fadeOut( 'slow' );
208 } );
209 } )
210 };
211
212 $.WCRBP.basic_init_metabox = function() {
213 //$(document.body).on('keyup change', '.wc_rbp_selling_price', $.WCRBP.validate_selling_price);
214
215 if( $( "input.wc_rbp_checkbox" ).size() > 0 ) {
216 $( "input.wc_rbp_checkbox" ).wcrbp_checkbox();
217 }
218
219 if( $( ".wcrbpvariationbx" ).size() > 0 ) {
220 $.WCRBP.add_variation_selectbox();
221 }
222
223 if( $( ".wcrbp-tabs" ).size() > 0 ) {
224 $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) );
225 $.WCRBP.render_wootabs();
226 $.WCRBP.move_selectbox_metabox();
227 $.WCRBP.render_price_status();
228 }
229
230 $( 'body' ).on( 'blur', '#wc-rbp-product-editor :input', function() {
231 $.WCRBP.render_price_status();
232 } );
233
234 $( "body" ).on( "click", 'div#wc-rbp-product-editor #wc_rbp_update_price', $.WCRBP.action_save_product_prices );
235 $( "body" )
236 .on( "click", 'div#wc-rbp-product-editor #wc_rbp_clear_trasient', $.WCRBP.action_clear_product_prices );
237
238 };
239
240 /**
241 * Internal Functions
242 */
243 $.fn.wcrbp_checkbox = function() {
244 return this.each( function() {
245 var $this = $( this ),
246 size = $this.attr( 'data-size' ),
247 color = $this.attr( 'data-color' ),
248 secondaryColor = $this.attr( 'data-secondaryColor' ),
249 jackColor = $this.attr( "data-jackColor" ),
250 jackSecondaryColor = $this.attr( "data-jackSecondaryColor" ),
251 className = $this.attr( "data-className" ),
252 disabled = $this.attr( 'data-disabled' ),
253 disabledOpacity = $this.attr( "data-disabledOpacity" ),
254 speed = $this.attr( "data-speed" );
255
256 new Switchery( this, {
257 size: size,
258 color: color,
259 secondaryColor: secondaryColor,
260 jackColor: jackColor,
261 jackSecondaryColor: jackSecondaryColor,
262 className: className,
263 disabled: disabled,
264 disabledOpacity: disabledOpacity,
265 speed: speed
266 } );
267
268
269 } );
270 };
271
272 $( document ).ready( function() {
273 $.WCRBP.basic_init_metabox();
274 } );
275
276 $( window ).load( function() {
277 if( $( '#wc-rbp-product-editor' ).size() > 0 ) {
278 $.WCRBP.move_selectbox_metabox();
279 $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) );
280 }
281 } )
282
283 } )( jQuery, window, document );
284
285
1 (function(){function require(name){var module=require.modules[name];if(!module)throw new Error('failed to require "'+name+'"');if(!("exports"in module)&&typeof module.definition==="function"){module.client=module.component=true;module.definition.call(this,module.exports={},module);delete module.definition}return module.exports}require.loader="component";require.helper={};require.helper.semVerSort=function(a,b){var aArray=a.version.split(".");var bArray=b.version.split(".");for(var i=0;i<aArray.length;++i){var aInt=parseInt(aArray[i],10);var bInt=parseInt(bArray[i],10);if(aInt===bInt){var aLex=aArray[i].substr((""+aInt).length);var bLex=bArray[i].substr((""+bInt).length);if(aLex===""&&bLex!=="")return 1;if(aLex!==""&&bLex==="")return-1;if(aLex!==""&&bLex!=="")return aLex>bLex?1:-1;continue}else if(aInt>bInt){return 1}else{return-1}}return 0};require.latest=function(name,returnPath){function showError(name){throw new Error('failed to find latest module of "'+name+'"')}var versionRegexp=/(.*)~(.*)@v?(\d+\.\d+\.\d+[^\/]*)$/;var remoteRegexp=/(.*)~(.*)/;if(!remoteRegexp.test(name))showError(name);var moduleNames=Object.keys(require.modules);var semVerCandidates=[];var otherCandidates=[];for(var i=0;i<moduleNames.length;i++){var moduleName=moduleNames[i];if(new RegExp(name+"@").test(moduleName)){var version=moduleName.substr(name.length+1);var semVerMatch=versionRegexp.exec(moduleName);if(semVerMatch!=null){semVerCandidates.push({version:version,name:moduleName})}else{otherCandidates.push({version:version,name:moduleName})}}}if(semVerCandidates.concat(otherCandidates).length===0){showError(name)}if(semVerCandidates.length>0){var module=semVerCandidates.sort(require.helper.semVerSort).pop().name;if(returnPath===true){return module}return require(module)}var module=otherCandidates.sort(function(a,b){return a.name>b.name})[0].name;if(returnPath===true){return module}return require(module)};require.modules={};require.register=function(name,definition){require.modules[name]={definition:definition}};require.define=function(name,exports){require.modules[name]={exports:exports}};require.register("abpetkov~transitionize@0.0.3",function(exports,module){module.exports=Transitionize;function Transitionize(element,props){if(!(this instanceof Transitionize))return new Transitionize(element,props);this.element=element;this.props=props||{};this.init()}Transitionize.prototype.isSafari=function(){return/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)};Transitionize.prototype.init=function(){var transitions=[];for(var key in this.props){transitions.push(key+" "+this.props[key])}this.element.style.transition=transitions.join(", ");if(this.isSafari())this.element.style.webkitTransition=transitions.join(", ")}});require.register("ftlabs~fastclick@v0.6.11",function(exports,module){function FastClick(layer){"use strict";var oldOnClick,self=this;this.trackingClick=false;this.trackingClickStart=0;this.targetElement=null;this.touchStartX=0;this.touchStartY=0;this.lastTouchIdentifier=0;this.touchBoundary=10;this.layer=layer;if(!layer||!layer.nodeType){throw new TypeError("Layer must be a document node")}this.onClick=function(){return FastClick.prototype.onClick.apply(self,arguments)};this.onMouse=function(){return FastClick.prototype.onMouse.apply(self,arguments)};this.onTouchStart=function(){return FastClick.prototype.onTouchStart.apply(self,arguments)};this.onTouchMove=function(){return FastClick.prototype.onTouchMove.apply(self,arguments)};this.onTouchEnd=function(){return FastClick.prototype.onTouchEnd.apply(self,arguments)};this.onTouchCancel=function(){return FastClick.prototype.onTouchCancel.apply(self,arguments)};if(FastClick.notNeeded(layer)){return}if(this.deviceIsAndroid){layer.addEventListener("mouseover",this.onMouse,true);layer.addEventListener("mousedown",this.onMouse,true);layer.addEventListener("mouseup",this.onMouse,true)}layer.addEventListener("click",this.onClick,true);layer.addEventListener("touchstart",this.onTouchStart,false);layer.addEventListener("touchmove",this.onTouchMove,false);layer.addEventListener("touchend",this.onTouchEnd,false);layer.addEventListener("touchcancel",this.onTouchCancel,false);if(!Event.prototype.stopImmediatePropagation){layer.removeEventListener=function(type,callback,capture){var rmv=Node.prototype.removeEventListener;if(type==="click"){rmv.call(layer,type,callback.hijacked||callback,capture)}else{rmv.call(layer,type,callback,capture)}};layer.addEventListener=function(type,callback,capture){var adv=Node.prototype.addEventListener;if(type==="click"){adv.call(layer,type,callback.hijacked||(callback.hijacked=function(event){if(!event.propagationStopped){callback(event)}}),capture)}else{adv.call(layer,type,callback,capture)}}}if(typeof layer.onclick==="function"){oldOnClick=layer.onclick;layer.addEventListener("click",function(event){oldOnClick(event)},false);layer.onclick=null}}FastClick.prototype.deviceIsAndroid=navigator.userAgent.indexOf("Android")>0;FastClick.prototype.deviceIsIOS=/iP(ad|hone|od)/.test(navigator.userAgent);FastClick.prototype.deviceIsIOS4=FastClick.prototype.deviceIsIOS&&/OS 4_\d(_\d)?/.test(navigator.userAgent);FastClick.prototype.deviceIsIOSWithBadTarget=FastClick.prototype.deviceIsIOS&&/OS ([6-9]|\d{2})_\d/.test(navigator.userAgent);FastClick.prototype.needsClick=function(target){"use strict";switch(target.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(target.disabled){return true}break;case"input":if(this.deviceIsIOS&&target.type==="file"||target.disabled){return true}break;case"label":case"video":return true}return/\bneedsclick\b/.test(target.className)};FastClick.prototype.needsFocus=function(target){"use strict";switch(target.nodeName.toLowerCase()){case"textarea":return true;case"select":return!this.deviceIsAndroid;case"input":switch(target.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return false}return!target.disabled&&!target.readOnly;default:return/\bneedsfocus\b/.test(target.className)}};FastClick.prototype.sendClick=function(targetElement,event){"use strict";var clickEvent,touch;if(document.activeElement&&document.activeElement!==targetElement){document.activeElement.blur()}touch=event.changedTouches[0];clickEvent=document.createEvent("MouseEvents");clickEvent.initMouseEvent(this.determineEventType(targetElement),true,true,window,1,touch.screenX,touch.screenY,touch.clientX,touch.clientY,false,false,false,false,0,null);clickEvent.forwardedTouchEvent=true;targetElement.dispatchEvent(clickEvent)};FastClick.prototype.determineEventType=function(targetElement){"use strict";if(this.deviceIsAndroid&&targetElement.tagName.toLowerCase()==="select"){return"mousedown"}return"click"};FastClick.prototype.focus=function(targetElement){"use strict";var length;if(this.deviceIsIOS&&targetElement.setSelectionRange&&targetElement.type.indexOf("date")!==0&&targetElement.type!=="time"){length=targetElement.value.length;targetElement.setSelectionRange(length,length)}else{targetElement.focus()}};FastClick.prototype.updateScrollParent=function(targetElement){"use strict";var scrollParent,parentElement;scrollParent=targetElement.fastClickScrollParent;if(!scrollParent||!scrollParent.contains(targetElement)){parentElement=targetElement;do{if(parentElement.scrollHeight>parentElement.offsetHeight){scrollParent=parentElement;targetElement.fastClickScrollParent=parentElement;break}parentElement=parentElement.parentElement}while(parentElement)}if(scrollParent){scrollParent.fastClickLastScrollTop=scrollParent.scrollTop}};FastClick.prototype.getTargetElementFromEventTarget=function(eventTarget){"use strict";if(eventTarget.nodeType===Node.TEXT_NODE){return eventTarget.parentNode}return eventTarget};FastClick.prototype.onTouchStart=function(event){"use strict";var targetElement,touch,selection;if(event.targetTouches.length>1){return true}targetElement=this.getTargetElementFromEventTarget(event.target);touch=event.targetTouches[0];if(this.deviceIsIOS){selection=window.getSelection();if(selection.rangeCount&&!selection.isCollapsed){return true}if(!this.deviceIsIOS4){if(touch.identifier===this.lastTouchIdentifier){event.preventDefault();return false}this.lastTouchIdentifier=touch.identifier;this.updateScrollParent(targetElement)}}this.trackingClick=true;this.trackingClickStart=event.timeStamp;this.targetElement=targetElement;this.touchStartX=touch.pageX;this.touchStartY=touch.pageY;if(event.timeStamp-this.lastClickTime<200){event.preventDefault()}return true};FastClick.prototype.touchHasMoved=function(event){"use strict";var touch=event.changedTouches[0],boundary=this.touchBoundary;if(Math.abs(touch.pageX-this.touchStartX)>boundary||Math.abs(touch.pageY-this.touchStartY)>boundary){return true}return false};FastClick.prototype.onTouchMove=function(event){"use strict";if(!this.trackingClick){return true}if(this.targetElement!==this.getTargetElementFromEventTarget(event.target)||this.touchHasMoved(event)){this.trackingClick=false;this.targetElement=null}return true};FastClick.prototype.findControl=function(labelElement){"use strict";if(labelElement.control!==undefined){return labelElement.control}if(labelElement.htmlFor){return document.getElementById(labelElement.htmlFor)}return labelElement.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")};FastClick.prototype.onTouchEnd=function(event){"use strict";var forElement,trackingClickStart,targetTagName,scrollParent,touch,targetElement=this.targetElement;if(!this.trackingClick){return true}if(event.timeStamp-this.lastClickTime<200){this.cancelNextClick=true;return true}this.cancelNextClick=false;this.lastClickTime=event.timeStamp;trackingClickStart=this.trackingClickStart;this.trackingClick=false;this.trackingClickStart=0;if(this.deviceIsIOSWithBadTarget){touch=event.changedTouches[0];targetElement=document.elementFromPoint(touch.pageX-window.pageXOffset,touch.pageY-window.pageYOffset)||targetElement;targetElement.fastClickScrollParent=this.targetElement.fastClickScrollParent}targetTagName=targetElement.tagName.toLowerCase();if(targetTagName==="label"){forElement=this.findControl(targetElement);if(forElement){this.focus(targetElement);if(this.deviceIsAndroid){return false}targetElement=forElement}}else if(this.needsFocus(targetElement)){if(event.timeStamp-trackingClickStart>100||this.deviceIsIOS&&window.top!==window&&targetTagName==="input"){this.targetElement=null;return false}this.focus(targetElement);if(!this.deviceIsIOS4||targetTagName!=="select"){this.targetElement=null;event.preventDefault()}return false}if(this.deviceIsIOS&&!this.deviceIsIOS4){scrollParent=targetElement.fastClickScrollParent;if(scrollParent&&scrollParent.fastClickLastScrollTop!==scrollParent.scrollTop){return true}}if(!this.needsClick(targetElement)){event.preventDefault();this.sendClick(targetElement,event)}return false};FastClick.prototype.onTouchCancel=function(){"use strict";this.trackingClick=false;this.targetElement=null};FastClick.prototype.onMouse=function(event){"use strict";if(!this.targetElement){return true}if(event.forwardedTouchEvent){return true}if(!event.cancelable){return true}if(!this.needsClick(this.targetElement)||this.cancelNextClick){if(event.stopImmediatePropagation){event.stopImmediatePropagation()}else{event.propagationStopped=true}event.stopPropagation();event.preventDefault();return false}return true};FastClick.prototype.onClick=function(event){"use strict";var permitted;if(this.trackingClick){this.targetElement=null;this.trackingClick=false;return true}if(event.target.type==="submit"&&event.detail===0){return true}permitted=this.onMouse(event);if(!permitted){this.targetElement=null}return permitted};FastClick.prototype.destroy=function(){"use strict";var layer=this.layer;if(this.deviceIsAndroid){layer.removeEventListener("mouseover",this.onMouse,true);layer.removeEventListener("mousedown",this.onMouse,true);layer.removeEventListener("mouseup",this.onMouse,true)}layer.removeEventListener("click",this.onClick,true);layer.removeEventListener("touchstart",this.onTouchStart,false);layer.removeEventListener("touchmove",this.onTouchMove,false);layer.removeEventListener("touchend",this.onTouchEnd,false);layer.removeEventListener("touchcancel",this.onTouchCancel,false)};FastClick.notNeeded=function(layer){"use strict";var metaViewport;var chromeVersion;if(typeof window.ontouchstart==="undefined"){return true}chromeVersion=+(/Chrome\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1];if(chromeVersion){if(FastClick.prototype.deviceIsAndroid){metaViewport=document.querySelector("meta[name=viewport]");if(metaViewport){if(metaViewport.content.indexOf("user-scalable=no")!==-1){return true}if(chromeVersion>31&&window.innerWidth<=window.screen.width){return true}}}else{return true}}if(layer.style.msTouchAction==="none"){return true}return false};FastClick.attach=function(layer){"use strict";return new FastClick(layer)};if(typeof define!=="undefined"&&define.amd){define(function(){"use strict";return FastClick})}else if(typeof module!=="undefined"&&module.exports){module.exports=FastClick.attach;module.exports.FastClick=FastClick}else{window.FastClick=FastClick}});require.register("component~indexof@0.0.3",function(exports,module){module.exports=function(arr,obj){if(arr.indexOf)return arr.indexOf(obj);for(var i=0;i<arr.length;++i){if(arr[i]===obj)return i}return-1}});require.register("component~classes@1.2.1",function(exports,module){var index=require("component~indexof@0.0.3");var re=/\s+/;var toString=Object.prototype.toString;module.exports=function(el){return new ClassList(el)};function ClassList(el){if(!el)throw new Error("A DOM element reference is required");this.el=el;this.list=el.classList}ClassList.prototype.add=function(name){if(this.list){this.list.add(name);return this}var arr=this.array();var i=index(arr,name);if(!~i)arr.push(name);this.el.className=arr.join(" ");return this};ClassList.prototype.remove=function(name){if("[object RegExp]"==toString.call(name)){return this.removeMatching(name)}if(this.list){this.list.remove(name);return this}var arr=this.array();var i=index(arr,name);if(~i)arr.splice(i,1);this.el.className=arr.join(" ");return this};ClassList.prototype.removeMatching=function(re){var arr=this.array();for(var i=0;i<arr.length;i++){if(re.test(arr[i])){this.remove(arr[i])}}return this};ClassList.prototype.toggle=function(name,force){if(this.list){if("undefined"!==typeof force){if(force!==this.list.toggle(name,force)){this.list.toggle(name)}}else{this.list.toggle(name)}return this}if("undefined"!==typeof force){if(!force){this.remove(name)}else{this.add(name)}}else{if(this.has(name)){this.remove(name)}else{this.add(name)}}return this};ClassList.prototype.array=function(){var str=this.el.className.replace(/^\s+|\s+$/g,"");var arr=str.split(re);if(""===arr[0])arr.shift();return arr};ClassList.prototype.has=ClassList.prototype.contains=function(name){return this.list?this.list.contains(name):!!~index(this.array(),name)}});require.register("component~event@0.1.4",function(exports,module){var bind=window.addEventListener?"addEventListener":"attachEvent",unbind=window.removeEventListener?"removeEventListener":"detachEvent",prefix=bind!=="addEventListener"?"on":"";exports.bind=function(el,type,fn,capture){el[bind](prefix+type,fn,capture||false);return fn};exports.unbind=function(el,type,fn,capture){el[unbind](prefix+type,fn,capture||false);return fn}});require.register("component~query@0.0.3",function(exports,module){function one(selector,el){return el.querySelector(selector)}exports=module.exports=function(selector,el){el=el||document;return one(selector,el)};exports.all=function(selector,el){el=el||document;return el.querySelectorAll(selector)};exports.engine=function(obj){if(!obj.one)throw new Error(".one callback required");if(!obj.all)throw new Error(".all callback required");one=obj.one;exports.all=obj.all;return exports}});require.register("component~matches-selector@0.1.5",function(exports,module){var query=require("component~query@0.0.3");var proto=Element.prototype;var vendor=proto.matches||proto.webkitMatchesSelector||proto.mozMatchesSelector||proto.msMatchesSelector||proto.oMatchesSelector;module.exports=match;function match(el,selector){if(!el||el.nodeType!==1)return false;if(vendor)return vendor.call(el,selector);var nodes=query.all(selector,el.parentNode);for(var i=0;i<nodes.length;++i){if(nodes[i]==el)return true}return false}});require.register("component~closest@0.1.4",function(exports,module){var matches=require("component~matches-selector@0.1.5");module.exports=function(element,selector,checkYoSelf,root){element=checkYoSelf?{parentNode:element}:element;root=root||document;while((element=element.parentNode)&&element!==document){if(matches(element,selector))return element;if(element===root)return}}});require.register("component~delegate@0.2.3",function(exports,module){var closest=require("component~closest@0.1.4"),event=require("component~event@0.1.4");exports.bind=function(el,selector,type,fn,capture){return event.bind(el,type,function(e){var target=e.target||e.srcElement;e.delegateTarget=closest(target,selector,true,el);if(e.delegateTarget)fn.call(el,e)},capture)};exports.unbind=function(el,type,fn,capture){event.unbind(el,type,fn,capture)}});require.register("component~events@1.0.9",function(exports,module){var events=require("component~event@0.1.4");var delegate=require("component~delegate@0.2.3");module.exports=Events;function Events(el,obj){if(!(this instanceof Events))return new Events(el,obj);if(!el)throw new Error("element required");if(!obj)throw new Error("object required");this.el=el;this.obj=obj;this._events={}}Events.prototype.sub=function(event,method,cb){this._events[event]=this._events[event]||{};this._events[event][method]=cb};Events.prototype.bind=function(event,method){var e=parse(event);var el=this.el;var obj=this.obj;var name=e.name;var method=method||"on"+name;var args=[].slice.call(arguments,2);function cb(){var a=[].slice.call(arguments).concat(args);obj[method].apply(obj,a)}if(e.selector){cb=delegate.bind(el,e.selector,name,cb)}else{events.bind(el,name,cb)}this.sub(name,method,cb);return cb};Events.prototype.unbind=function(event,method){if(0==arguments.length)return this.unbindAll();if(1==arguments.length)return this.unbindAllOf(event);var bindings=this._events[event];if(!bindings)return;var cb=bindings[method];if(!cb)return;events.unbind(this.el,event,cb)};Events.prototype.unbindAll=function(){for(var event in this._events){this.unbindAllOf(event)}};Events.prototype.unbindAllOf=function(event){var bindings=this._events[event];if(!bindings)return;for(var method in bindings){this.unbind(event,method)}};function parse(event){var parts=event.split(/ +/);return{name:parts.shift(),selector:parts.join(" ")}}});require.register("switchery",function(exports,module){var transitionize=require("abpetkov~transitionize@0.0.3"),fastclick=require("ftlabs~fastclick@v0.6.11"),classes=require("component~classes@1.2.1"),events=require("component~events@1.0.9");module.exports=Switchery;var defaults={color:"#64bd63",secondaryColor:"#dfdfdf",jackColor:"#fff",jackSecondaryColor:null,className:"switchery",disabled:false,disabledOpacity:.5,speed:"0.4s",size:"default"};function Switchery(element,options){if(!(this instanceof Switchery))return new Switchery(element,options);this.element=element;this.options=options||{};for(var i in defaults){if(this.options[i]==null){this.options[i]=defaults[i]}}if(this.element!=null&&this.element.type=="checkbox")this.init();if(this.isDisabled()===true)this.disable()}Switchery.prototype.hide=function(){this.element.style.display="none"};Switchery.prototype.show=function(){var switcher=this.create();this.insertAfter(this.element,switcher)};Switchery.prototype.create=function(){this.switcher=document.createElement("span");this.jack=document.createElement("small");this.switcher.appendChild(this.jack);this.switcher.className=this.options.className;this.events=events(this.switcher,this);return this.switcher};Switchery.prototype.insertAfter=function(reference,target){reference.parentNode.insertBefore(target,reference.nextSibling)};Switchery.prototype.setPosition=function(clicked){var checked=this.isChecked(),switcher=this.switcher,jack=this.jack;if(clicked&&checked)checked=false;else if(clicked&&!checked)checked=true;if(checked===true){this.element.checked=true;if(window.getComputedStyle)jack.style.left=parseInt(window.getComputedStyle(switcher).width)-parseInt(window.getComputedStyle(jack).width)+"px";else jack.style.left=parseInt(switcher.currentStyle["width"])-parseInt(jack.currentStyle["width"])+"px";if(this.options.color)this.colorize();this.setSpeed()}else{jack.style.left=0;this.element.checked=false;this.switcher.style.boxShadow="inset 0 0 0 0 "+this.options.secondaryColor;this.switcher.style.borderColor=this.options.secondaryColor;this.switcher.style.backgroundColor=this.options.secondaryColor!==defaults.secondaryColor?this.options.secondaryColor:"#fff";this.jack.style.backgroundColor=this.options.jackSecondaryColor!==this.options.jackColor?this.options.jackSecondaryColor:this.options.jackColor;this.setSpeed()}};Switchery.prototype.setSpeed=function(){var switcherProp={},jackProp={"background-color":this.options.speed,left:this.options.speed.replace(/[a-z]/,"")/2+"s"};if(this.isChecked()){switcherProp={border:this.options.speed,"box-shadow":this.options.speed,"background-color":this.options.speed.replace(/[a-z]/,"")*3+"s"}}else{switcherProp={border:this.options.speed,"box-shadow":this.options.speed}}transitionize(this.switcher,switcherProp);transitionize(this.jack,jackProp)};Switchery.prototype.setSize=function(){var small="switchery-small",normal="switchery-default",large="switchery-large";switch(this.options.size){case"small":classes(this.switcher).add(small);break;case"large":classes(this.switcher).add(large);break;default:classes(this.switcher).add(normal);break}};Switchery.prototype.colorize=function(){var switcherHeight=this.switcher.offsetHeight/2;this.switcher.style.backgroundColor=this.options.color;this.switcher.style.borderColor=this.options.color;this.switcher.style.boxShadow="inset 0 0 0 "+switcherHeight+"px "+this.options.color;this.jack.style.backgroundColor=this.options.jackColor};Switchery.prototype.handleOnchange=function(state){if(document.dispatchEvent){var event=document.createEvent("HTMLEvents");event.initEvent("change",true,true);this.element.dispatchEvent(event)}else{this.element.fireEvent("onchange")}};Switchery.prototype.handleChange=function(){var self=this,el=this.element;if(el.addEventListener){el.addEventListener("change",function(){self.setPosition()})}else{el.attachEvent("onchange",function(){self.setPosition()})}};Switchery.prototype.handleClick=function(){var switcher=this.switcher;fastclick(switcher);this.events.bind("click","bindClick")};Switchery.prototype.bindClick=function(){var parent=this.element.parentNode.tagName.toLowerCase(),labelParent=parent==="label"?false:true;this.setPosition(labelParent);this.handleOnchange(this.element.checked)};Switchery.prototype.markAsSwitched=function(){this.element.setAttribute("data-switchery",true)};Switchery.prototype.markedAsSwitched=function(){return this.element.getAttribute("data-switchery")};Switchery.prototype.init=function(){this.hide();this.show();this.setSize();this.setPosition();this.markAsSwitched();this.handleChange();this.handleClick()};Switchery.prototype.isChecked=function(){return this.element.checked};Switchery.prototype.isDisabled=function(){return this.options.disabled||this.element.disabled||this.element.readOnly};Switchery.prototype.destroy=function(){this.events.unbind()};Switchery.prototype.enable=function(){if(this.options.disabled)this.options.disabled=false;if(this.element.disabled)this.element.disabled=false;if(this.element.readOnly)this.element.readOnly=false;this.switcher.style.opacity=1;this.events.bind("click","bindClick")};Switchery.prototype.disable=function(){if(!this.options.disabled)this.options.disabled=true;if(!this.element.disabled)this.element.disabled=true;if(!this.element.readOnly)this.element.readOnly=true;this.switcher.style.opacity=this.options.disabledOpacity;this.destroy()}});if(typeof exports=="object"){module.exports=require("switchery")}else if(typeof define=="function"&&define.amd){define("Switchery",[],function(){return require("switchery")})}else{(this||window)["Switchery"]=require("switchery")}})();
...\ No newline at end of file ...\ No newline at end of file
1 /*! selectize.js - v0.12.4 | https://github.com/selectize/selectize.js | Apache License (v2) */
2 !function(a,b){"function"==typeof define&&define.amd?define("sifter",b):"object"==typeof exports?module.exports=b():a.Sifter=b()}(this,function(){var a=function(a,b){this.items=a,this.settings=b||{diacritics:!0}};a.prototype.tokenize=function(a){if(a=e(String(a||"").toLowerCase()),!a||!a.length)return[];var b,c,d,g,i=[],j=a.split(/ +/);for(b=0,c=j.length;b<c;b++){if(d=f(j[b]),this.settings.diacritics)for(g in h)h.hasOwnProperty(g)&&(d=d.replace(new RegExp(g,"g"),h[g]));i.push({string:j[b],regex:new RegExp(d,"i")})}return i},a.prototype.iterator=function(a,b){var c;c=g(a)?Array.prototype.forEach||function(a){for(var b=0,c=this.length;b<c;b++)a(this[b],b,this)}:function(a){for(var b in this)this.hasOwnProperty(b)&&a(this[b],b,this)},c.apply(a,[b])},a.prototype.getScoreFunction=function(a,b){var c,e,f,g,h;c=this,a=c.prepareSearch(a,b),f=a.tokens,e=a.options.fields,g=f.length,h=a.options.nesting;var i=function(a,b){var c,d;return a?(a=String(a||""),d=a.search(b.regex),d===-1?0:(c=b.string.length/a.length,0===d&&(c+=.5),c)):0},j=function(){var a=e.length;return a?1===a?function(a,b){return i(d(b,e[0],h),a)}:function(b,c){for(var f=0,g=0;f<a;f++)g+=i(d(c,e[f],h),b);return g/a}:function(){return 0}}();return g?1===g?function(a){return j(f[0],a)}:"and"===a.options.conjunction?function(a){for(var b,c=0,d=0;c<g;c++){if(b=j(f[c],a),b<=0)return 0;d+=b}return d/g}:function(a){for(var b=0,c=0;b<g;b++)c+=j(f[b],a);return c/g}:function(){return 0}},a.prototype.getSortFunction=function(a,c){var e,f,g,h,i,j,k,l,m,n,o;if(g=this,a=g.prepareSearch(a,c),o=!a.query&&c.sort_empty||c.sort,m=function(a,b){return"$score"===a?b.score:d(g.items[b.id],a,c.nesting)},i=[],o)for(e=0,f=o.length;e<f;e++)(a.query||"$score"!==o[e].field)&&i.push(o[e]);if(a.query){for(n=!0,e=0,f=i.length;e<f;e++)if("$score"===i[e].field){n=!1;break}n&&i.unshift({field:"$score",direction:"desc"})}else for(e=0,f=i.length;e<f;e++)if("$score"===i[e].field){i.splice(e,1);break}for(l=[],e=0,f=i.length;e<f;e++)l.push("desc"===i[e].direction?-1:1);return j=i.length,j?1===j?(h=i[0].field,k=l[0],function(a,c){return k*b(m(h,a),m(h,c))}):function(a,c){var d,e,f;for(d=0;d<j;d++)if(f=i[d].field,e=l[d]*b(m(f,a),m(f,c)))return e;return 0}:null},a.prototype.prepareSearch=function(a,b){if("object"==typeof a)return a;b=c({},b);var d=b.fields,e=b.sort,f=b.sort_empty;return d&&!g(d)&&(b.fields=[d]),e&&!g(e)&&(b.sort=[e]),f&&!g(f)&&(b.sort_empty=[f]),{options:b,query:String(a||"").toLowerCase(),tokens:this.tokenize(a),total:0,items:[]}},a.prototype.search=function(a,b){var c,d,e,f,g=this;return d=this.prepareSearch(a,b),b=d.options,a=d.query,f=b.score||g.getScoreFunction(d),a.length?g.iterator(g.items,function(a,e){c=f(a),(b.filter===!1||c>0)&&d.items.push({score:c,id:e})}):g.iterator(g.items,function(a,b){d.items.push({score:1,id:b})}),e=g.getSortFunction(d,b),e&&d.items.sort(e),d.total=d.items.length,"number"==typeof b.limit&&(d.items=d.items.slice(0,b.limit)),d};var b=function(a,b){return"number"==typeof a&&"number"==typeof b?a>b?1:a<b?-1:0:(a=i(String(a||"")),b=i(String(b||"")),a>b?1:b>a?-1:0)},c=function(a,b){var c,d,e,f;for(c=1,d=arguments.length;c<d;c++)if(f=arguments[c])for(e in f)f.hasOwnProperty(e)&&(a[e]=f[e]);return a},d=function(a,b,c){if(a&&b){if(!c)return a[b];for(var d=b.split(".");d.length&&(a=a[d.shift()]););return a}},e=function(a){return(a+"").replace(/^\s+|\s+$|/g,"")},f=function(a){return(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},g=Array.isArray||"undefined"!=typeof $&&$.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"},i=function(){var a,b,c,d,e="",f={};for(c in h)if(h.hasOwnProperty(c))for(d=h[c].substring(2,h[c].length-1),e+=d,a=0,b=d.length;a<b;a++)f[d.charAt(a)]=c;var g=new RegExp("["+e+"]","g");return function(a){return a.replace(g,function(a){return f[a]}).toLowerCase()}}();return a}),function(a,b){"function"==typeof define&&define.amd?define("microplugin",b):"object"==typeof exports?module.exports=b():a.MicroPlugin=b()}(this,function(){var a={};a.mixin=function(a){a.plugins={},a.prototype.initializePlugins=function(a){var c,d,e,f=this,g=[];if(f.plugins={names:[],settings:{},requested:{},loaded:{}},b.isArray(a))for(c=0,d=a.length;c<d;c++)"string"==typeof a[c]?g.push(a[c]):(f.plugins.settings[a[c].name]=a[c].options,g.push(a[c].name));else if(a)for(e in a)a.hasOwnProperty(e)&&(f.plugins.settings[e]=a[e],g.push(e));for(;g.length;)f.require(g.shift())},a.prototype.loadPlugin=function(b){var c=this,d=c.plugins,e=a.plugins[b];if(!a.plugins.hasOwnProperty(b))throw new Error('Unable to find "'+b+'" plugin');d.requested[b]=!0,d.loaded[b]=e.fn.apply(c,[c.plugins.settings[b]||{}]),d.names.push(b)},a.prototype.require=function(a){var b=this,c=b.plugins;if(!b.plugins.loaded.hasOwnProperty(a)){if(c.requested[a])throw new Error('Plugin has circular dependency ("'+a+'")');b.loadPlugin(a)}return c.loaded[a]},a.define=function(b,c){a.plugins[b]={name:b,fn:c}}};var b={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}};return a}),function(a,b){"function"==typeof define&&define.amd?define("selectize",["jquery","sifter","microplugin"],b):"object"==typeof exports?module.exports=b(require("jquery"),require("sifter"),require("microplugin")):a.Selectize=b(a.jQuery,a.Sifter,a.MicroPlugin)}(this,function(a,b,c){"use strict";var d=function(a,b){if("string"!=typeof b||b.length){var c="string"==typeof b?new RegExp(b,"i"):b,d=function(a){var b=0;if(3===a.nodeType){var e=a.data.search(c);if(e>=0&&a.data.length>0){var f=a.data.match(c),g=document.createElement("span");g.className="highlight";var h=a.splitText(e),i=(h.splitText(f[0].length),h.cloneNode(!0));g.appendChild(i),h.parentNode.replaceChild(g,h),b=1}}else if(1===a.nodeType&&a.childNodes&&!/(script|style)/i.test(a.tagName))for(var j=0;j<a.childNodes.length;++j)j+=d(a.childNodes[j]);return b};return a.each(function(){d(this)})}};a.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var a=this.parentNode;a.replaceChild(this.firstChild,this),a.normalize()}).end()};var e=function(){};e.prototype={on:function(a,b){this._events=this._events||{},this._events[a]=this._events[a]||[],this._events[a].push(b)},off:function(a,b){var c=arguments.length;return 0===c?delete this._events:1===c?delete this._events[a]:(this._events=this._events||{},void(a in this._events!=!1&&this._events[a].splice(this._events[a].indexOf(b),1)))},trigger:function(a){if(this._events=this._events||{},a in this._events!=!1)for(var b=0;b<this._events[a].length;b++)this._events[a][b].apply(this,Array.prototype.slice.call(arguments,1))}},e.mixin=function(a){for(var b=["on","off","trigger"],c=0;c<b.length;c++)a.prototype[b[c]]=e.prototype[b[c]]};var f=/Mac/.test(navigator.userAgent),g=65,h=13,i=27,j=37,k=38,l=80,m=39,n=40,o=78,p=8,q=46,r=16,s=f?91:17,t=f?18:17,u=9,v=1,w=2,x=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,y=function(a){return"undefined"!=typeof a},z=function(a){return"undefined"==typeof a||null===a?null:"boolean"==typeof a?a?"1":"0":a+""},A=function(a){return(a+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},B={};B.before=function(a,b,c){var d=a[b];a[b]=function(){return c.apply(a,arguments),d.apply(a,arguments)}},B.after=function(a,b,c){var d=a[b];a[b]=function(){var b=d.apply(a,arguments);return c.apply(a,arguments),b}};var C=function(a){var b=!1;return function(){b||(b=!0,a.apply(this,arguments))}},D=function(a,b){var c;return function(){var d=this,e=arguments;window.clearTimeout(c),c=window.setTimeout(function(){a.apply(d,e)},b)}},E=function(a,b,c){var d,e=a.trigger,f={};a.trigger=function(){var c=arguments[0];return b.indexOf(c)===-1?e.apply(a,arguments):void(f[c]=arguments)},c.apply(a,[]),a.trigger=e;for(d in f)f.hasOwnProperty(d)&&e.apply(a,f[d])},F=function(a,b,c,d){a.on(b,c,function(b){for(var c=b.target;c&&c.parentNode!==a[0];)c=c.parentNode;return b.currentTarget=c,d.apply(this,[b])})},G=function(a){var b={};if("selectionStart"in a)b.start=a.selectionStart,b.length=a.selectionEnd-b.start;else if(document.selection){a.focus();var c=document.selection.createRange(),d=document.selection.createRange().text.length;c.moveStart("character",-a.value.length),b.start=c.text.length-d,b.length=d}return b},H=function(a,b,c){var d,e,f={};if(c)for(d=0,e=c.length;d<e;d++)f[c[d]]=a.css(c[d]);else f=a.css();b.css(f)},I=function(b,c){if(!b)return 0;var d=a("<test>").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(b).appendTo("body");H(c,d,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var e=d.width();return d.remove(),e},J=function(a){var b=null,c=function(c,d){var e,f,g,h,i,j,k,l;c=c||window.event||{},d=d||{},c.metaKey||c.altKey||(d.force||a.data("grow")!==!1)&&(e=a.val(),c.type&&"keydown"===c.type.toLowerCase()&&(f=c.keyCode,g=f>=97&&f<=122||f>=65&&f<=90||f>=48&&f<=57||32===f,f===q||f===p?(l=G(a[0]),l.length?e=e.substring(0,l.start)+e.substring(l.start+l.length):f===p&&l.start?e=e.substring(0,l.start-1)+e.substring(l.start+1):f===q&&"undefined"!=typeof l.start&&(e=e.substring(0,l.start)+e.substring(l.start+1))):g&&(j=c.shiftKey,k=String.fromCharCode(c.keyCode),k=j?k.toUpperCase():k.toLowerCase(),e+=k)),h=a.attr("placeholder"),!e&&h&&(e=h),i=I(e,a)+4,i!==b&&(b=i,a.width(i),a.triggerHandler("resize")))};a.on("keydown keyup update blur",c),c()},K=function(a){var b=document.createElement("div");return b.appendChild(a.cloneNode(!0)),b.innerHTML},L=function(a,b){b||(b={});var c="Selectize";console.error(c+": "+a),b.explanation&&(console.group&&console.group(),console.error(b.explanation),console.group&&console.groupEnd())},M=function(c,d){var e,f,g,h,i=this;h=c[0],h.selectize=i;var j=window.getComputedStyle&&window.getComputedStyle(h,null);if(g=j?j.getPropertyValue("direction"):h.currentStyle&&h.currentStyle.direction,g=g||c.parents("[dir]:first").attr("dir")||"",a.extend(i,{order:0,settings:d,$input:c,tabIndex:c.attr("tabindex")||"",tagType:"select"===h.tagName.toLowerCase()?v:w,rtl:/rtl/i.test(g),eventNS:".selectize"+ ++M.count,highlightedValue:null,isOpen:!1,isDisabled:!1,isRequired:c.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===d.loadThrottle?i.onSearchChange:D(i.onSearchChange,d.loadThrottle)}),i.sifter=new b(this.options,{diacritics:d.diacritics}),i.settings.options){for(e=0,f=i.settings.options.length;e<f;e++)i.registerOption(i.settings.options[e]);delete i.settings.options}if(i.settings.optgroups){for(e=0,f=i.settings.optgroups.length;e<f;e++)i.registerOptionGroup(i.settings.optgroups[e]);delete i.settings.optgroups}i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup()};return e.mixin(M),"undefined"!=typeof c?c.mixin(M):L("Dependency MicroPlugin is missing",{explanation:'Make sure you either: (1) are using the "standalone" version of Selectize, or (2) require MicroPlugin before you load Selectize.'}),a.extend(M.prototype,{setup:function(){var b,c,d,e,g,h,i,j,k,l,m=this,n=m.settings,o=m.eventNS,p=a(window),q=a(document),u=m.$input;if(i=m.settings.mode,j=u.attr("class")||"",b=a("<div>").addClass(n.wrapperClass).addClass(j).addClass(i),c=a("<div>").addClass(n.inputClass).addClass("items").appendTo(b),d=a('<input type="text" autocomplete="off" />').appendTo(c).attr("tabindex",u.is(":disabled")?"-1":m.tabIndex),h=a(n.dropdownParent||b),e=a("<div>").addClass(n.dropdownClass).addClass(i).hide().appendTo(h),g=a("<div>").addClass(n.dropdownContentClass).appendTo(e),(l=u.attr("id"))&&(d.attr("id",l+"-selectized"),a("label[for='"+l+"']").attr("for",l+"-selectized")),m.settings.copyClassesToDropdown&&e.addClass(j),b.css({width:u[0].style.width}),m.plugins.names.length&&(k="plugin-"+m.plugins.names.join(" plugin-"),b.addClass(k),e.addClass(k)),(null===n.maxItems||n.maxItems>1)&&m.tagType===v&&u.attr("multiple","multiple"),m.settings.placeholder&&d.attr("placeholder",n.placeholder),!m.settings.splitOn&&m.settings.delimiter){var w=m.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");m.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}u.attr("autocorrect")&&d.attr("autocorrect",u.attr("autocorrect")),u.attr("autocapitalize")&&d.attr("autocapitalize",u.attr("autocapitalize")),m.$wrapper=b,m.$control=c,m.$control_input=d,m.$dropdown=e,m.$dropdown_content=g,e.on("mouseenter","[data-selectable]",function(){return m.onOptionHover.apply(m,arguments)}),e.on("mousedown click","[data-selectable]",function(){return m.onOptionSelect.apply(m,arguments)}),F(c,"mousedown","*:not(input)",function(){return m.onItemSelect.apply(m,arguments)}),J(d),c.on({mousedown:function(){return m.onMouseDown.apply(m,arguments)},click:function(){return m.onClick.apply(m,arguments)}}),d.on({mousedown:function(a){a.stopPropagation()},keydown:function(){return m.onKeyDown.apply(m,arguments)},keyup:function(){return m.onKeyUp.apply(m,arguments)},keypress:function(){return m.onKeyPress.apply(m,arguments)},resize:function(){m.positionDropdown.apply(m,[])},blur:function(){return m.onBlur.apply(m,arguments)},focus:function(){return m.ignoreBlur=!1,m.onFocus.apply(m,arguments)},paste:function(){return m.onPaste.apply(m,arguments)}}),q.on("keydown"+o,function(a){m.isCmdDown=a[f?"metaKey":"ctrlKey"],m.isCtrlDown=a[f?"altKey":"ctrlKey"],m.isShiftDown=a.shiftKey}),q.on("keyup"+o,function(a){a.keyCode===t&&(m.isCtrlDown=!1),a.keyCode===r&&(m.isShiftDown=!1),a.keyCode===s&&(m.isCmdDown=!1)}),q.on("mousedown"+o,function(a){if(m.isFocused){if(a.target===m.$dropdown[0]||a.target.parentNode===m.$dropdown[0])return!1;m.$control.has(a.target).length||a.target===m.$control[0]||m.blur(a.target)}}),p.on(["scroll"+o,"resize"+o].join(" "),function(){m.isOpen&&m.positionDropdown.apply(m,arguments)}),p.on("mousemove"+o,function(){m.ignoreHover=!1}),this.revertSettings={$children:u.children().detach(),tabindex:u.attr("tabindex")},u.attr("tabindex",-1).hide().after(m.$wrapper),a.isArray(n.items)&&(m.setValue(n.items),delete n.items),x&&u.on("invalid"+o,function(a){a.preventDefault(),m.isInvalid=!0,m.refreshState()}),m.updateOriginalInput(),m.refreshItems(),m.refreshState(),m.updatePlaceholder(),m.isSetup=!0,u.is(":disabled")&&m.disable(),m.on("change",this.onChange),u.data("selectize",m),u.addClass("selectized"),m.trigger("initialize"),n.preload===!0&&m.onSearchChange("")},setupTemplates:function(){var b=this,c=b.settings.labelField,d=b.settings.optgroupLabelField,e={optgroup:function(a){return'<div class="optgroup">'+a.html+"</div>"},optgroup_header:function(a,b){return'<div class="optgroup-header">'+b(a[d])+"</div>"},option:function(a,b){return'<div class="option">'+b(a[c])+"</div>"},item:function(a,b){return'<div class="item">'+b(a[c])+"</div>"},option_create:function(a,b){return'<div class="create">Add <strong>'+b(a.input)+"</strong>&hellip;</div>"}};b.settings.render=a.extend({},e,b.settings.render)},setupCallbacks:function(){var a,b,c={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(a in c)c.hasOwnProperty(a)&&(b=this.settings[c[a]],b&&this.on(a,b))},onClick:function(a){var b=this;b.isFocused||(b.focus(),a.preventDefault())},onMouseDown:function(b){var c=this,d=b.isDefaultPrevented();a(b.target);if(c.isFocused){if(b.target!==c.$control_input[0])return"single"===c.settings.mode?c.isOpen?c.close():c.open():d||c.setActiveItem(null),!1}else d||window.setTimeout(function(){c.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(b){var c=this;return c.isFull()||c.isInputHidden||c.isLocked?void b.preventDefault():void(c.settings.splitOn&&setTimeout(function(){var b=c.$control_input.val();if(b.match(c.settings.splitOn))for(var d=a.trim(b).split(c.settings.splitOn),e=0,f=d.length;e<f;e++)c.createItem(d[e])},0))},onKeyPress:function(a){if(this.isLocked)return a&&a.preventDefault();var b=String.fromCharCode(a.keyCode||a.which);return this.settings.create&&"multi"===this.settings.mode&&b===this.settings.delimiter?(this.createItem(),a.preventDefault(),!1):void 0},onKeyDown:function(a){var b=(a.target===this.$control_input[0],this);if(b.isLocked)return void(a.keyCode!==u&&a.preventDefault());switch(a.keyCode){case g:if(b.isCmdDown)return void b.selectAll();break;case i:return void(b.isOpen&&(a.preventDefault(),a.stopPropagation(),b.close()));case o:if(!a.ctrlKey||a.altKey)break;case n:if(!b.isOpen&&b.hasOptions)b.open();else if(b.$activeOption){b.ignoreHover=!0;var c=b.getAdjacentOption(b.$activeOption,1);c.length&&b.setActiveOption(c,!0,!0)}return void a.preventDefault();case l:if(!a.ctrlKey||a.altKey)break;case k:if(b.$activeOption){b.ignoreHover=!0;var d=b.getAdjacentOption(b.$activeOption,-1);d.length&&b.setActiveOption(d,!0,!0)}return void a.preventDefault();case h:return void(b.isOpen&&b.$activeOption&&(b.onOptionSelect({currentTarget:b.$activeOption}),a.preventDefault()));case j:return void b.advanceSelection(-1,a);case m:return void b.advanceSelection(1,a);case u:return b.settings.selectOnTab&&b.isOpen&&b.$activeOption&&(b.onOptionSelect({currentTarget:b.$activeOption}),b.isFull()||a.preventDefault()),void(b.settings.create&&b.createItem()&&a.preventDefault());case p:case q:return void b.deleteSelection(a)}return!b.isFull()&&!b.isInputHidden||(f?a.metaKey:a.ctrlKey)?void 0:void a.preventDefault()},onKeyUp:function(a){var b=this;if(b.isLocked)return a&&a.preventDefault();var c=b.$control_input.val()||"";b.lastValue!==c&&(b.lastValue=c,b.onSearchChange(c),b.refreshOptions(),b.trigger("type",c))},onSearchChange:function(a){var b=this,c=b.settings.load;c&&(b.loadedSearches.hasOwnProperty(a)||(b.loadedSearches[a]=!0,b.load(function(d){c.apply(b,[a,d])})))},onFocus:function(a){var b=this,c=b.isFocused;return b.isDisabled?(b.blur(),a&&a.preventDefault(),!1):void(b.ignoreFocus||(b.isFocused=!0,"focus"===b.settings.preload&&b.onSearchChange(""),c||b.trigger("focus"),b.$activeItems.length||(b.showInput(),b.setActiveItem(null),b.refreshOptions(!!b.settings.openOnFocus)),b.refreshState()))},onBlur:function(a,b){var c=this;if(c.isFocused&&(c.isFocused=!1,!c.ignoreFocus)){if(!c.ignoreBlur&&document.activeElement===c.$dropdown_content[0])return c.ignoreBlur=!0,void c.onFocus(a);var d=function(){c.close(),c.setTextboxValue(""),c.setActiveItem(null),c.setActiveOption(null),c.setCaret(c.items.length),c.refreshState(),b&&b.focus&&b.focus(),c.ignoreFocus=!1,c.trigger("blur")};c.ignoreFocus=!0,c.settings.create&&c.settings.createOnBlur?c.createItem(null,!1,d):d()}},onOptionHover:function(a){this.ignoreHover||this.setActiveOption(a.currentTarget,!1)},onOptionSelect:function(b){var c,d,e=this;b.preventDefault&&(b.preventDefault(),b.stopPropagation()),d=a(b.currentTarget),d.hasClass("create")?e.createItem(null,function(){e.settings.closeAfterSelect&&e.close()}):(c=d.attr("data-value"),"undefined"!=typeof c&&(e.lastQuery=null,e.setTextboxValue(""),e.addItem(c),e.settings.closeAfterSelect?e.close():!e.settings.hideSelected&&b.type&&/mouse/.test(b.type)&&e.setActiveOption(e.getOption(c))))},onItemSelect:function(a){var b=this;b.isLocked||"multi"===b.settings.mode&&(a.preventDefault(),b.setActiveItem(a.currentTarget,a))},load:function(a){var b=this,c=b.$wrapper.addClass(b.settings.loadingClass);b.loading++,a.apply(b,[function(a){b.loading=Math.max(b.loading-1,0),a&&a.length&&(b.addOption(a),b.refreshOptions(b.isFocused&&!b.isInputHidden)),b.loading||c.removeClass(b.settings.loadingClass),b.trigger("load",a)}])},setTextboxValue:function(a){var b=this.$control_input,c=b.val()!==a;c&&(b.val(a).triggerHandler("update"),this.lastValue=a)},getValue:function(){return this.tagType===v&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(a,b){var c=b?[]:["change"];E(this,c,function(){this.clear(b),this.addItems(a,b)})},setActiveItem:function(b,c){var d,e,f,g,h,i,j,k,l=this;if("single"!==l.settings.mode){if(b=a(b),!b.length)return a(l.$activeItems).removeClass("active"),l.$activeItems=[],void(l.isFocused&&l.showInput());if(d=c&&c.type.toLowerCase(),"mousedown"===d&&l.isShiftDown&&l.$activeItems.length){for(k=l.$control.children(".active:last"),g=Array.prototype.indexOf.apply(l.$control[0].childNodes,[k[0]]),h=Array.prototype.indexOf.apply(l.$control[0].childNodes,[b[0]]),g>h&&(j=g,g=h,h=j),e=g;e<=h;e++)i=l.$control[0].childNodes[e],l.$activeItems.indexOf(i)===-1&&(a(i).addClass("active"),l.$activeItems.push(i));c.preventDefault()}else"mousedown"===d&&l.isCtrlDown||"keydown"===d&&this.isShiftDown?b.hasClass("active")?(f=l.$activeItems.indexOf(b[0]),l.$activeItems.splice(f,1),b.removeClass("active")):l.$activeItems.push(b.addClass("active")[0]):(a(l.$activeItems).removeClass("active"),l.$activeItems=[b.addClass("active")[0]]);l.hideInput(),this.isFocused||l.focus()}},setActiveOption:function(b,c,d){var e,f,g,h,i,j=this;j.$activeOption&&j.$activeOption.removeClass("active"),j.$activeOption=null,b=a(b),b.length&&(j.$activeOption=b.addClass("active"),!c&&y(c)||(e=j.$dropdown_content.height(),f=j.$activeOption.outerHeight(!0),c=j.$dropdown_content.scrollTop()||0,g=j.$activeOption.offset().top-j.$dropdown_content.offset().top+c,h=g,i=g-e+f,g+f>e+c?j.$dropdown_content.stop().animate({scrollTop:i},d?j.settings.scrollDuration:0):g<c&&j.$dropdown_content.stop().animate({scrollTop:h},d?j.settings.scrollDuration:0)))},selectAll:function(){var a=this;"single"!==a.settings.mode&&(a.$activeItems=Array.prototype.slice.apply(a.$control.children(":not(input)").addClass("active")),a.$activeItems.length&&(a.hideInput(),a.close()),a.focus())},hideInput:function(){var a=this;a.setTextboxValue(""),a.$control_input.css({opacity:0,position:"absolute",left:a.rtl?1e4:-1e4}),a.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0}),this.isInputHidden=!1},focus:function(){var a=this;a.isDisabled||(a.ignoreFocus=!0,a.$control_input[0].focus(),window.setTimeout(function(){a.ignoreFocus=!1,a.onFocus()},0))},blur:function(a){this.$control_input[0].blur(),this.onBlur(null,a)},getScoreFunction:function(a){return this.sifter.getScoreFunction(a,this.getSearchOptions())},getSearchOptions:function(){var a=this.settings,b=a.sortField;return"string"==typeof b&&(b=[{field:b}]),{fields:a.searchField,conjunction:a.searchConjunction,sort:b}},search:function(b){var c,d,e,f=this,g=f.settings,h=this.getSearchOptions();if(g.score&&(e=f.settings.score.apply(this,[b]),"function"!=typeof e))throw new Error('Selectize "score" setting must be a function that returns a function');if(b!==f.lastQuery?(f.lastQuery=b,d=f.sifter.search(b,a.extend(h,{score:e})),f.currentResults=d):d=a.extend(!0,{},f.currentResults),g.hideSelected)for(c=d.items.length-1;c>=0;c--)f.items.indexOf(z(d.items[c].id))!==-1&&d.items.splice(c,1);return d},refreshOptions:function(b){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;"undefined"==typeof b&&(b=!0);var t=this,u=a.trim(t.$control_input.val()),v=t.search(u),w=t.$dropdown_content,x=t.$activeOption&&z(t.$activeOption.attr("data-value"));for(g=v.items.length,"number"==typeof t.settings.maxOptions&&(g=Math.min(g,t.settings.maxOptions)),h={},i=[],c=0;c<g;c++)for(j=t.options[v.items[c].id],k=t.render("option",j),l=j[t.settings.optgroupField]||"",m=a.isArray(l)?l:[l],e=0,f=m&&m.length;e<f;e++)l=m[e],t.optgroups.hasOwnProperty(l)||(l=""),h.hasOwnProperty(l)||(h[l]=document.createDocumentFragment(),i.push(l)),h[l].appendChild(k);for(this.settings.lockOptgroupOrder&&i.sort(function(a,b){var c=t.optgroups[a].$order||0,d=t.optgroups[b].$order||0;return c-d}),n=document.createDocumentFragment(),c=0,g=i.length;c<g;c++)l=i[c],t.optgroups.hasOwnProperty(l)&&h[l].childNodes.length?(o=document.createDocumentFragment(),o.appendChild(t.render("optgroup_header",t.optgroups[l])),o.appendChild(h[l]),n.appendChild(t.render("optgroup",a.extend({},t.optgroups[l],{html:K(o),dom:o})))):n.appendChild(h[l]);if(w.html(n),t.settings.highlight&&v.query.length&&v.tokens.length)for(w.removeHighlight(),c=0,g=v.tokens.length;c<g;c++)d(w,v.tokens[c].regex);if(!t.settings.hideSelected)for(c=0,g=t.items.length;c<g;c++)t.getOption(t.items[c]).addClass("selected");p=t.canCreate(u),p&&(w.prepend(t.render("option_create",{input:u})),s=a(w[0].childNodes[0])),t.hasOptions=v.items.length>0||p,t.hasOptions?(v.items.length>0?(r=x&&t.getOption(x),r&&r.length?q=r:"single"===t.settings.mode&&t.items.length&&(q=t.getOption(t.items[0])),q&&q.length||(q=s&&!t.settings.addPrecedence?t.getAdjacentOption(s,1):w.find("[data-selectable]:first"))):q=s,t.setActiveOption(q),b&&!t.isOpen&&t.open()):(t.setActiveOption(null),b&&t.isOpen&&t.close())},addOption:function(b){var c,d,e,f=this;if(a.isArray(b))for(c=0,d=b.length;c<d;c++)f.addOption(b[c]);else(e=f.registerOption(b))&&(f.userOptions[e]=!0,f.lastQuery=null,f.trigger("option_add",e,b))},registerOption:function(a){var b=z(a[this.settings.valueField]);return"undefined"!=typeof b&&null!==b&&!this.options.hasOwnProperty(b)&&(a.$order=a.$order||++this.order,this.options[b]=a,b)},registerOptionGroup:function(a){var b=z(a[this.settings.optgroupValueField]);return!!b&&(a.$order=a.$order||++this.order,this.optgroups[b]=a,b)},addOptionGroup:function(a,b){b[this.settings.optgroupValueField]=a,(a=this.registerOptionGroup(b))&&this.trigger("optgroup_add",a,b)},removeOptionGroup:function(a){this.optgroups.hasOwnProperty(a)&&(delete this.optgroups[a],this.renderCache={},this.trigger("optgroup_remove",a))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(b,c){var d,e,f,g,h,i,j,k=this;if(b=z(b),f=z(c[k.settings.valueField]),null!==b&&k.options.hasOwnProperty(b)){if("string"!=typeof f)throw new Error("Value must be set in option data");j=k.options[b].$order,f!==b&&(delete k.options[b],g=k.items.indexOf(b),g!==-1&&k.items.splice(g,1,f)),c.$order=c.$order||j,k.options[f]=c,h=k.renderCache.item,i=k.renderCache.option,h&&(delete h[b],delete h[f]),i&&(delete i[b],delete i[f]),k.items.indexOf(f)!==-1&&(d=k.getItem(b),e=a(k.render("item",c)),d.hasClass("active")&&e.addClass("active"),d.replaceWith(e)),k.lastQuery=null,k.isOpen&&k.refreshOptions(!1)}},removeOption:function(a,b){var c=this;a=z(a);var d=c.renderCache.item,e=c.renderCache.option;d&&delete d[a],e&&delete e[a],delete c.userOptions[a],delete c.options[a],c.lastQuery=null,c.trigger("option_remove",a),c.removeItem(a,b)},clearOptions:function(){var a=this;a.loadedSearches={},a.userOptions={},a.renderCache={},a.options=a.sifter.items={},a.lastQuery=null,a.trigger("option_clear"),a.clear()},getOption:function(a){return this.getElementWithValue(a,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(b,c){var d=this.$dropdown.find("[data-selectable]"),e=d.index(b)+c;return e>=0&&e<d.length?d.eq(e):a()},getElementWithValue:function(b,c){if(b=z(b),"undefined"!=typeof b&&null!==b)for(var d=0,e=c.length;d<e;d++)if(c[d].getAttribute("data-value")===b)return a(c[d]);return a()},getItem:function(a){return this.getElementWithValue(a,this.$control.children())},addItems:function(b,c){for(var d=a.isArray(b)?b:[b],e=0,f=d.length;e<f;e++)this.isPending=e<f-1,this.addItem(d[e],c)},addItem:function(b,c){var d=c?[]:["change"];E(this,d,function(){var d,e,f,g,h,i=this,j=i.settings.mode;return b=z(b),i.items.indexOf(b)!==-1?void("single"===j&&i.close()):void(i.options.hasOwnProperty(b)&&("single"===j&&i.clear(c),"multi"===j&&i.isFull()||(d=a(i.render("item",i.options[b])),h=i.isFull(),i.items.splice(i.caretPos,0,b),i.insertAtCaret(d),(!i.isPending||!h&&i.isFull())&&i.refreshState(),i.isSetup&&(f=i.$dropdown_content.find("[data-selectable]"),i.isPending||(e=i.getOption(b),g=i.getAdjacentOption(e,1).attr("data-value"),i.refreshOptions(i.isFocused&&"single"!==j),g&&i.setActiveOption(i.getOption(g))),!f.length||i.isFull()?i.close():i.positionDropdown(),i.updatePlaceholder(),i.trigger("item_add",b,d),i.updateOriginalInput({silent:c})))))})},removeItem:function(b,c){var d,e,f,g=this;d=b instanceof a?b:g.getItem(b),b=z(d.attr("data-value")),e=g.items.indexOf(b),e!==-1&&(d.remove(),d.hasClass("active")&&(f=g.$activeItems.indexOf(d[0]),g.$activeItems.splice(f,1)),g.items.splice(e,1),g.lastQuery=null,!g.settings.persist&&g.userOptions.hasOwnProperty(b)&&g.removeOption(b,c),e<g.caretPos&&g.setCaret(g.caretPos-1),g.refreshState(),g.updatePlaceholder(),g.updateOriginalInput({silent:c}),g.positionDropdown(),g.trigger("item_remove",b,d))},createItem:function(b,c){var d=this,e=d.caretPos;b=b||a.trim(d.$control_input.val()||"");var f=arguments[arguments.length-1];if("function"!=typeof f&&(f=function(){}),"boolean"!=typeof c&&(c=!0),!d.canCreate(b))return f(),!1;d.lock();var g="function"==typeof d.settings.create?this.settings.create:function(a){var b={};return b[d.settings.labelField]=a,b[d.settings.valueField]=a,b},h=C(function(a){if(d.unlock(),!a||"object"!=typeof a)return f();var b=z(a[d.settings.valueField]);return"string"!=typeof b?f():(d.setTextboxValue(""),d.addOption(a),d.setCaret(e),d.addItem(b),d.refreshOptions(c&&"single"!==d.settings.mode),void f(a))}),i=g.apply(this,[b,h]);return"undefined"!=typeof i&&h(i),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){this.refreshValidityState(),this.refreshClasses()},refreshValidityState:function(){if(!this.isRequired)return!1;var a=!this.items.length;this.isInvalid=a,this.$control_input.prop("required",a),this.$input.prop("required",!a)},refreshClasses:function(){var b=this,c=b.isFull(),d=b.isLocked;b.$wrapper.toggleClass("rtl",b.rtl),b.$control.toggleClass("focus",b.isFocused).toggleClass("disabled",b.isDisabled).toggleClass("required",b.isRequired).toggleClass("invalid",b.isInvalid).toggleClass("locked",d).toggleClass("full",c).toggleClass("not-full",!c).toggleClass("input-active",b.isFocused&&!b.isInputHidden).toggleClass("dropdown-active",b.isOpen).toggleClass("has-options",!a.isEmptyObject(b.options)).toggleClass("has-items",b.items.length>0),b.$control_input.data("grow",!c&&!d)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(a){var b,c,d,e,f=this;if(a=a||{},f.tagType===v){for(d=[],b=0,c=f.items.length;b<c;b++)e=f.options[f.items[b]][f.settings.labelField]||"",d.push('<option value="'+A(f.items[b])+'" selected="selected">'+A(e)+"</option>");d.length||this.$input.attr("multiple")||d.push('<option value="" selected="selected"></option>'),
3 f.$input.html(d.join(""))}else f.$input.val(f.getValue()),f.$input.attr("value",f.$input.val());f.isSetup&&(a.silent||f.trigger("change",f.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var a=this.$control_input;this.items.length?a.removeAttr("placeholder"):a.attr("placeholder",this.settings.placeholder),a.triggerHandler("update",{force:!0})}},open:function(){var a=this;a.isLocked||a.isOpen||"multi"===a.settings.mode&&a.isFull()||(a.focus(),a.isOpen=!0,a.refreshState(),a.$dropdown.css({visibility:"hidden",display:"block"}),a.positionDropdown(),a.$dropdown.css({visibility:"visible"}),a.trigger("dropdown_open",a.$dropdown))},close:function(){var a=this,b=a.isOpen;"single"===a.settings.mode&&a.items.length&&(a.hideInput(),a.$control_input.blur()),a.isOpen=!1,a.$dropdown.hide(),a.setActiveOption(null),a.refreshState(),b&&a.trigger("dropdown_close",a.$dropdown)},positionDropdown:function(){var a=this.$control,b="body"===this.settings.dropdownParent?a.offset():a.position();b.top+=a.outerHeight(!0),this.$dropdown.css({width:a.outerWidth(),top:b.top,left:b.left})},clear:function(a){var b=this;b.items.length&&(b.$control.children(":not(input)").remove(),b.items=[],b.lastQuery=null,b.setCaret(0),b.setActiveItem(null),b.updatePlaceholder(),b.updateOriginalInput({silent:a}),b.refreshState(),b.showInput(),b.trigger("clear"))},insertAtCaret:function(b){var c=Math.min(this.caretPos,this.items.length);0===c?this.$control.prepend(b):a(this.$control[0].childNodes[c]).before(b),this.setCaret(c+1)},deleteSelection:function(b){var c,d,e,f,g,h,i,j,k,l=this;if(e=b&&b.keyCode===p?-1:1,f=G(l.$control_input[0]),l.$activeOption&&!l.settings.hideSelected&&(i=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),g=[],l.$activeItems.length){for(k=l.$control.children(".active:"+(e>0?"last":"first")),h=l.$control.children(":not(input)").index(k),e>0&&h++,c=0,d=l.$activeItems.length;c<d;c++)g.push(a(l.$activeItems[c]).attr("data-value"));b&&(b.preventDefault(),b.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(e<0&&0===f.start&&0===f.length?g.push(l.items[l.caretPos-1]):e>0&&f.start===l.$control_input.val().length&&g.push(l.items[l.caretPos]));if(!g.length||"function"==typeof l.settings.onDelete&&l.settings.onDelete.apply(l,[g])===!1)return!1;for("undefined"!=typeof h&&l.setCaret(h);g.length;)l.removeItem(g.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),i&&(j=l.getOption(i),j.length&&l.setActiveOption(j)),!0},advanceSelection:function(a,b){var c,d,e,f,g,h,i=this;0!==a&&(i.rtl&&(a*=-1),c=a>0?"last":"first",d=G(i.$control_input[0]),i.isFocused&&!i.isInputHidden?(f=i.$control_input.val().length,g=a<0?0===d.start&&0===d.length:d.start===f,g&&!f&&i.advanceCaret(a,b)):(h=i.$control.children(".active:"+c),h.length&&(e=i.$control.children(":not(input)").index(h),i.setActiveItem(null),i.setCaret(a>0?e+1:e))))},advanceCaret:function(a,b){var c,d,e=this;0!==a&&(c=a>0?"next":"prev",e.isShiftDown?(d=e.$control_input[c](),d.length&&(e.hideInput(),e.setActiveItem(d),b&&b.preventDefault())):e.setCaret(e.caretPos+a))},setCaret:function(b){var c=this;if(b="single"===c.settings.mode?c.items.length:Math.max(0,Math.min(c.items.length,b)),!c.isPending){var d,e,f,g;for(f=c.$control.children(":not(input)"),d=0,e=f.length;d<e;d++)g=a(f[d]).detach(),d<b?c.$control_input.before(g):c.$control.append(g)}c.caretPos=b},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){var a=this;a.$input.prop("disabled",!0),a.$control_input.prop("disabled",!0).prop("tabindex",-1),a.isDisabled=!0,a.lock()},enable:function(){var a=this;a.$input.prop("disabled",!1),a.$control_input.prop("disabled",!1).prop("tabindex",a.tabIndex),a.isDisabled=!1,a.unlock()},destroy:function(){var b=this,c=b.eventNS,d=b.revertSettings;b.trigger("destroy"),b.off(),b.$wrapper.remove(),b.$dropdown.remove(),b.$input.html("").append(d.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:d.tabindex}).show(),b.$control_input.removeData("grow"),b.$input.removeData("selectize"),a(window).off(c),a(document).off(c),a(document.body).off(c),delete b.$input[0].selectize},render:function(b,c){var d,e,f="",g=!1,h=this;return"option"!==b&&"item"!==b||(d=z(c[h.settings.valueField]),g=!!d),g&&(y(h.renderCache[b])||(h.renderCache[b]={}),h.renderCache[b].hasOwnProperty(d))?h.renderCache[b][d]:(f=a(h.settings.render[b].apply(this,[c,A])),"option"===b||"option_create"===b?f.attr("data-selectable",""):"optgroup"===b&&(e=c[h.settings.optgroupValueField]||"",f.attr("data-group",e)),"option"!==b&&"item"!==b||f.attr("data-value",d||""),g&&(h.renderCache[b][d]=f[0]),f[0])},clearCache:function(a){var b=this;"undefined"==typeof a?b.renderCache={}:delete b.renderCache[a]},canCreate:function(a){var b=this;if(!b.settings.create)return!1;var c=b.settings.createFilter;return a.length&&("function"!=typeof c||c.apply(b,[a]))&&("string"!=typeof c||new RegExp(c).test(a))&&(!(c instanceof RegExp)||c.test(a))}}),M.count=0,M.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:!0,render:{}},a.fn.selectize=function(b){var c=a.fn.selectize.defaults,d=a.extend({},c,b),e=d.dataAttr,f=d.labelField,g=d.valueField,h=d.optgroupField,i=d.optgroupLabelField,j=d.optgroupValueField,k=function(b,c){var h,i,j,k,l=b.attr(e);if(l)for(c.options=JSON.parse(l),h=0,i=c.options.length;h<i;h++)c.items.push(c.options[h][g]);else{var m=a.trim(b.val()||"");if(!d.allowEmptyOption&&!m.length)return;for(j=m.split(d.delimiter),h=0,i=j.length;h<i;h++)k={},k[f]=j[h],k[g]=j[h],c.options.push(k);c.items=j}},l=function(b,c){var k,l,m,n,o=c.options,p={},q=function(a){var b=e&&a.attr(e);return"string"==typeof b&&b.length?JSON.parse(b):null},r=function(b,e){b=a(b);var i=z(b.val());if(i||d.allowEmptyOption)if(p.hasOwnProperty(i)){if(e){var j=p[i][h];j?a.isArray(j)?j.push(e):p[i][h]=[j,e]:p[i][h]=e}}else{var k=q(b)||{};k[f]=k[f]||b.text(),k[g]=k[g]||i,k[h]=k[h]||e,p[i]=k,o.push(k),b.is(":selected")&&c.items.push(i)}},s=function(b){var d,e,f,g,h;for(b=a(b),f=b.attr("label"),f&&(g=q(b)||{},g[i]=f,g[j]=f,c.optgroups.push(g)),h=a("option",b),d=0,e=h.length;d<e;d++)r(h[d],f)};for(c.maxItems=b.attr("multiple")?null:1,n=b.children(),k=0,l=n.length;k<l;k++)m=n[k].tagName.toLowerCase(),"optgroup"===m?s(n[k]):"option"===m&&r(n[k])};return this.each(function(){if(!this.selectize){var e,f=a(this),g=this.tagName.toLowerCase(),h=f.attr("placeholder")||f.attr("data-placeholder");h||d.allowEmptyOption||(h=f.children('option[value=""]').text());var i={placeholder:h,options:[],optgroups:[],items:[]};"select"===g?l(f,i):k(f,i),e=new M(f,a.extend(!0,{},c,i,b))}})},a.fn.selectize.defaults=M.defaults,a.fn.selectize.support={validity:x},M.define("drag_drop",function(b){if(!a.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var c=this;c.lock=function(){var a=c.lock;return function(){var b=c.$control.data("sortable");return b&&b.disable(),a.apply(c,arguments)}}(),c.unlock=function(){var a=c.unlock;return function(){var b=c.$control.data("sortable");return b&&b.enable(),a.apply(c,arguments)}}(),c.setup=function(){var b=c.setup;return function(){b.apply(this,arguments);var d=c.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:c.isLocked,start:function(a,b){b.placeholder.css("width",b.helper.css("width")),d.css({overflow:"visible"})},stop:function(){d.css({overflow:"hidden"});var b=c.$activeItems?c.$activeItems.slice():null,e=[];d.children("[data-value]").each(function(){e.push(a(this).attr("data-value"))}),c.setValue(e),c.setActiveItem(b)}})}}()}}),M.define("dropdown_header",function(b){var c=this;b=a.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(a){return'<div class="'+a.headerClass+'"><div class="'+a.titleRowClass+'"><span class="'+a.labelClass+'">'+a.title+'</span><a href="javascript:void(0)" class="'+a.closeClass+'">&times;</a></div></div>'}},b),c.setup=function(){var d=c.setup;return function(){d.apply(c,arguments),c.$dropdown_header=a(b.html(b)),c.$dropdown.prepend(c.$dropdown_header)}}()}),M.define("optgroup_columns",function(b){var c=this;b=a.extend({equalizeWidth:!0,equalizeHeight:!0},b),this.getAdjacentOption=function(b,c){var d=b.closest("[data-group]").find("[data-selectable]"),e=d.index(b)+c;return e>=0&&e<d.length?d.eq(e):a()},this.onKeyDown=function(){var a=c.onKeyDown;return function(b){var d,e,f,g;return!this.isOpen||b.keyCode!==j&&b.keyCode!==m?a.apply(this,arguments):(c.ignoreHover=!0,g=this.$activeOption.closest("[data-group]"),d=g.find("[data-selectable]").index(this.$activeOption),g=b.keyCode===j?g.prev("[data-group]"):g.next("[data-group]"),f=g.find("[data-selectable]"),e=f.eq(Math.min(f.length-1,d)),void(e.length&&this.setActiveOption(e)))}}();var d=function(){var a,b=d.width,c=document;return"undefined"==typeof b&&(a=c.createElement("div"),a.innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',a=a.firstChild,c.body.appendChild(a),b=d.width=a.offsetWidth-a.clientWidth,c.body.removeChild(a)),b},e=function(){var e,f,g,h,i,j,k;if(k=a("[data-group]",c.$dropdown_content),f=k.length,f&&c.$dropdown_content.width()){if(b.equalizeHeight){for(g=0,e=0;e<f;e++)g=Math.max(g,k.eq(e).height());k.css({height:g})}b.equalizeWidth&&(j=c.$dropdown_content.innerWidth()-d(),h=Math.round(j/f),k.css({width:h}),f>1&&(i=j-h*(f-1),k.eq(f-1).css({width:i})))}};(b.equalizeHeight||b.equalizeWidth)&&(B.after(this,"positionDropdown",e),B.after(this,"refreshOptions",e))}),M.define("remove_button",function(b){b=a.extend({label:"&times;",title:"Remove",className:"remove",append:!0},b);var c=function(b,c){c.className="remove-single";var d=b,e='<a href="javascript:void(0)" class="'+c.className+'" tabindex="-1" title="'+A(c.title)+'">'+c.label+"</a>",f=function(a,b){return a+b};b.setup=function(){var g=d.setup;return function(){if(c.append){var h=a(d.$input.context).attr("id"),i=(a("#"+h),d.settings.render.item);d.settings.render.item=function(a){return f(i.apply(b,arguments),e)}}g.apply(b,arguments),b.$control.on("click","."+c.className,function(a){a.preventDefault(),d.isLocked||d.clear()})}}()},d=function(b,c){var d=b,e='<a href="javascript:void(0)" class="'+c.className+'" tabindex="-1" title="'+A(c.title)+'">'+c.label+"</a>",f=function(a,b){var c=a.search(/(<\/[^>]+>\s*)$/);return a.substring(0,c)+b+a.substring(c)};b.setup=function(){var g=d.setup;return function(){if(c.append){var h=d.settings.render.item;d.settings.render.item=function(a){return f(h.apply(b,arguments),e)}}g.apply(b,arguments),b.$control.on("click","."+c.className,function(b){if(b.preventDefault(),!d.isLocked){var c=a(b.currentTarget).parent();d.setActiveItem(c),d.deleteSelection()&&d.setCaret(d.items.length)}})}}()};return"single"===this.settings.mode?void c(this,b):void d(this,b)}),M.define("restore_on_backspace",function(a){var b=this;a.text=a.text||function(a){return a[this.settings.labelField]},this.onKeyDown=function(){var c=b.onKeyDown;return function(b){var d,e;return b.keyCode===p&&""===this.$control_input.val()&&!this.$activeItems.length&&(d=this.caretPos-1,d>=0&&d<this.items.length)?(e=this.options[this.items[d]],this.deleteSelection(b)&&(this.setTextboxValue(a.text.apply(this,[e])),this.refreshOptions(!0)),void b.preventDefault()):c.apply(this,arguments)}}()}),M});
...\ No newline at end of file ...\ No newline at end of file
1 ;
2 ( function ($, window, document, undefined) {
3 'use strict';
4
5 $.WCRBP_SETTINGS = $.WCRBP_SETTINGS || {};
6
7 $.WCRBP_SETTINGS.addons_html = '';
8
9 $.WCRBP_SETTINGS.http_reffer = '';
10
11 $.WCRBP_SETTINGS.handle_settings_page_url = function () {
12 var id = window.location.hash;
13 jQuery('.wc_rbp_settings_submenu a').removeClass('current');
14 jQuery('.wc_rbp_settings_submenu a[href="' + id + '" ]').addClass('current');
15 if ( id == '' ) {
16 jQuery('.wc_rbp_settings_submenu a:first').addClass('current');
17 id = jQuery('.wc_rbp_settings_submenu a:first').attr('href');
18 }
19 $.WCRBP_SETTINGS.http_reffer = jQuery('input[name=_wp_http_referer').val();
20
21 $.WCRBP_SETTINGS.show_settings(id);
22 }
23
24 $.WCRBP_SETTINGS.show_settings = function (elem) {
25 jQuery('div.wc_rbp_settings_content').hide();
26 elem = elem.replace('#', '#settings_');
27 jQuery(elem).show();
28 }
29
30 $.WCRBP_SETTINGS.settings_click_handler = function () {
31 var id = jQuery(this).attr('href');
32 jQuery('.wc_rbp_settings_submenu a').removeClass('current');
33 jQuery(this).addClass('current');
34 $.WCRBP_SETTINGS.show_settings(id);
35 jQuery('input[name=_wp_http_referer').val($.WCRBP_SETTINGS.http_reffer + id);
36 }
37
38 $.WCRBP_SETTINGS.handle_activate_deactivate_addons = function (elem, $class) {
39 if ( typeof ( $class ) === 'undefined' ) $class = '.wc-rbp-deactivate-now';
40 var clicked = elem;
41 var slug = elem.parent().attr('data-pluginslug');
42 var parent_div = '.plugin-card-' + slug;
43 var height = jQuery(parent_div).innerHeight();
44 var width = jQuery(parent_div).innerWidth();
45 jQuery(parent_div + ' .wc_rbp_ajax_overlay').css('height', height + 'px').css('width', width + 'px').fadeIn();
46 clicked.attr('disabled', 'disable');
47 var link = clicked.attr('href');
48 jQuery.ajax({
49 method: 'GET',
50 url: link,
51 }).done(function (response) {
52 var status = response.success;
53 jQuery(parent_div + ' .wc_rbp_ajax_overlay').fadeOut();
54 clicked.removeAttr('disabled');
55 if ( status ) {
56 clicked.hide();
57 jQuery(parent_div).find($class).fadeIn();
58 }
59
60 jQuery(parent_div).find('.wc_rbp_ajax_response').hide().html(response.data.msg).fadeIn(function () {
61 setTimeout(function () {
62 jQuery(parent_div).find('.wc_rbp_ajax_response').fadeOut();
63 }, 5000);
64 });
65
66 jQuery.ajax({
67 method: 'GET',
68 url: ajaxurl + '?action=wc_rbp_get_addons_html',
69 }).done(function (response) {
70 addons_html = jQuery(response);
71 });
72
73 });
74 }
75
76
77 $(document).ready(function () {
78 if ( jQuery('div.wc_rbp_addon_listing').size() > 0 ) {
79 jQuery('p.submit').remove();
80 }
81
82 jQuery('select.wc-rbp-enhanced-select').selectize({
83 plugins: ['remove_button', 'restore_on_backspace', 'drag_drop'],
84 persist: false,
85 create: true,
86 });
87
88 jQuery('.wc_rbp_settings_submenu a').click($.WCRBP_SETTINGS.settings_click_handler);
89
90 if ( jQuery('.wc_rbp_settings_submenu').size() > 0 ) {
91 $.WCRBP_SETTINGS.handle_settings_page_url();
92 }
93
94 jQuery('.wc_rbp_addon_listing').on('click', '.wc-rbp-activate-now', function () {
95 $.WCRBP_SETTINGS.handle_activate_deactivate_addons(jQuery(this), '.wc-rbp-deactivate-now')
96 });
97
98 jQuery('.wc_rbp_addon_listing').on('click', '.wc-rbp-deactivate-now', function () {
99 $.WCRBP_SETTINGS.handle_activate_deactivate_addons(jQuery(this), '.wc-rbp-activate-now')
100 });
101
102 $.WCRBP_SETTINGS.addons_html = jQuery('.wc_rbp_addon_listing').clone();
103
104 jQuery('ul.wc_rbp_addons_category li a:first').addClass('current');
105
106 jQuery('ul.wc_rbp_addons_category li a').click(function () {
107 var cat = jQuery(this).attr('data-category');
108 var NewDis = 'div.wc-rbp-addon-' + cat;
109 jQuery('ul.wc_rbp_addons_category li a').removeClass('current');
110 jQuery(this).addClass('current');
111 jQuery('.wc_rbp_addon_listing').html($.WCRBP_SETTINGS.addons_html.find(NewDis).clone());
112 });
113
114 jQuery('ul.wc_rbp_addons_category li a').each(function () {
115 var category = jQuery(this).attr('data-category');
116 var catCount = jQuery('.wc-rbp-addon-' + category).size();
117 jQuery(this).append(' <span class="catCount"> (' + catCount + ') </span>');
118
119 });
120
121 jQuery('div.addons-search-form input.wp-filter-search').keyup(function () {
122 var val = jQuery(this).val();
123 var html_source = $.WCRBP_SETTINGS.addons_html.clone();
124 if ( val == '' ) {
125 jQuery('.wc_rbp_addon_listing').html(html_source);
126 jQuery('.wc-rbp-addon-all').show();
127 } else {
128 html_source = jQuery(html_source).find(".plugin-card:contains('" + val + "')").not().remove();
129 jQuery('.wc_rbp_addon_listing').html(html_source);
130 }
131 })
132
133 });
134
135 } )(jQuery, window, document);
1 !function(t,s,i,a){function e(s,i){this.element=t(s),this.$elem=t(this.element),this.settings=t.extend({},l,i),this._defaults=l,this._name=n,this.init()}var n="pwstabs",l={effect:"scale",defaultTab:1,containerWidth:"100%",tabsPosition:"horizontal",horizontalPosition:"top",verticalPosition:"left",responsive:!1,theme:"",rtl:!1};e.prototype={init:function(){var i=["scale","slideleft","slideright","slidetop","slidedown","none"],a=this.$elem,e=a.children("[data-pws-tab]");a.addClass("pws_tabs_list"),a.wrap('<div class="pws_tabs_container"></div>');var n=a.closest(".pws_tabs_container");if("100%"!==this.settings.containerWidth&&n.css("width",this.settings.containerWidth),"vertical"==this.settings.tabsPosition){if(n.closest(".pws_tab_single").length){var l=n.closest(".pws_tab_single").innerWidth();n.css("width",l)}"left"==this.settings.verticalPosition?n.addClass("pws_tabs_vertical pws_tabs_vertical_left"):n.addClass("pws_tabs_vertical pws_tabs_vertical_right")}else"top"==this.settings.horizontalPosition?n.addClass("pws_tabs_horizontal pws_tabs_horizontal_top"):n.addClass("pws_tabs_horizontal pws_tabs_horizontal_bottom");this.settings.rtl&&n.addClass("pws_tabs_rtl"),"none"==this.settings.effect&&n.addClass("pws_tabs_noeffect"),this.settings.theme&&n.addClass(this.settings.theme),t.inArray(this.settings.effect,i)>=0?n.addClass("pws_"+this.settings.effect):n.addClass("pws_scale"),e.addClass("pws_hide").hide(),"vertical"==this.settings.tabsPosition?"left"==this.settings.verticalPosition?n.prepend('<ul class="pws_tabs_controll"></ul>'):n.append('<ul class="pws_tabs_controll"></ul>'):"top"==this.settings.horizontalPosition?n.prepend('<ul class="pws_tabs_controll"></ul>'):n.append('<ul class="pws_tabs_controll"></ul>');var d=n.children(".pws_tabs_controll"),o=1;e.each(function(){t(this).attr("data-pws-tab-id",o);var s=t(this).data("pws-tab"),i=t(this).data("pws-tab-name");d.append('<li><a data-tab-id="'+s+'">'+i+"</a></li>"),t(this).addClass("pws_tab_single"),o++});var h=d.find("a"),p=d.find("li"),r=a.children('[data-pws-tab-id="'+this.settings.defaultTab+'"]');if(a.children("[data-pws-tab-icon]").each(function(){var s=t(this).attr("data-pws-tab"),i=t(this).attr("data-pws-tab-name"),a=t(this).attr("data-pws-tab-icon");""==i&&d.find('[data-tab-id="'+s+'"]').addClass("pws_tab_noname"),d.find('[data-tab-id="'+s+'"]').prepend('<i class="fa '+a+'"></i>')}),"vertical"==this.settings.tabsPosition){var _=n.innerWidth()/450,c=parseInt(h.css("font-size"))/_,w=parseInt(h.css("padding-left"))+parseInt(h.css("padding-right")),u=h.html().length*c+w,b=d.outerHeight(),f=n.outerWidth()-u,v=a.outerHeight();d.width(u),a.outerWidth(f),b>v&&a.css("min-height",b)}if(r.addClass("pws_show").show(),d.find('[data-tab-id="'+r.data("pws-tab")+'"]').addClass("pws_tab_active"),h.on("click",function(s){s.preventDefault(),h.removeClass("pws_tab_active"),t(this).addClass("pws_tab_active");var i=t(this).data("tab-id"),n=a.children('[data-pws-tab="'+i+'"]');e.removeClass("pws_show"),setTimeout(function(){e.hide(),n.show()},400),setTimeout(function(){n.addClass("pws_show")},450)}),this.settings.responsive){n.addClass("pws_tabs_responsive");var g=parseInt(d.children("li").length),m=100/g,C=Math.max.apply(null,p.map(function(){return t(this).height()}).get());t(s).on("resize load",{pluginSettings:this.settings},function(i){var e=i.data.pluginSettings,l=e.tabsPosition,o=e.containerWidth;t(s).width()<=960&&(n.width(""),p.css("width",m+"%"),h.each(function(){t(this).height(C)}),"vertical"==l&&(d.width(""),a.width(""),a.css("min-height",""),a.height(r.height()))),t(s).width()<=600?(n.find(".pws_responsive_small_menu").length<1&&t('<div class="pws_responsive_small_menu"><a data-visible="0"><i class="fa fa-bars"></i></a></div>').insertBefore(d),d.addClass("pws_tabs_menu_popup"),h.height(""),p.width(""),n.find("ul.pws_tabs_menu_popup").hide(),n.find(".pws_responsive_small_menu a").click(function(s){s.preventDefault(),"0"==t(this).attr("data-visible")?(n.find("ul.pws_tabs_menu_popup").show(),t(this).attr("data-visible","1")):(n.find("ul.pws_tabs_menu_popup").hide(),t(this).attr("data-visible","0"))}),n.find("ul.pws_tabs_menu_popup li a").on("click",function(s){s.preventDefault(),t(this).closest(".pws_tabs_menu_popup").hide(),n.find(".pws_responsive_small_menu a").attr("data-visible","0")})):t(s).width()>960?(n.css("width",o),p.width(""),h.height(""),n.find(".pws_responsive_small_menu").remove(),d.removeClass("pws_tabs_menu_popup"),d.show()):t(s).width()>600&&(n.find(".pws_responsive_small_menu").remove(),d.removeClass("pws_tabs_menu_popup"),d.show(),h.on("click",function(s){s.preventDefault(),t(this).parent().parent().show()}))})}}},t.fn[n]=function(t){return this.each(function(){new e(this,t)})}}(jQuery,window,document);
...\ No newline at end of file ...\ No newline at end of file
1 # Copyright (C) 2018 Role Based Price For WooCommerce
2 # This file is distributed under the same license as the Role Based Price For WooCommerce package.
3 msgid ""
4 msgstr ""
5 "Project-Id-Version: Role Based Price For WooCommerce 3.3\n"
6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-role-based-price\n"
7 "POT-Creation-Date: 2018-03-12 04:57:30+00:00\n"
8 "MIME-Version: 1.0\n"
9 "Content-Type: text/plain; charset=UTF-8\n"
10 "Content-Transfer-Encoding: 8bit\n"
11 "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14
15 #: bootstrap.php:157
16 msgid "Cloning instances of the class is forbidden."
17 msgstr ""
18
19 #: bootstrap.php:171
20 msgid "Unserializing instances of the class is forbidden."
21 msgstr ""
22
23 #: includes/admin/class-admin-init.php:72
24 msgid "Role Based Price For WooCommerce Welcome Page"
25 msgstr ""
26
27 #: includes/admin/class-admin-init.php:170
28 msgid "Settings"
29 msgstr ""
30
31 #: includes/admin/class-admin-init.php:171
32 msgid "Add-ons"
33 msgstr ""
34
35 #: includes/admin/class-admin-init.php:188
36 msgid "Docs"
37 msgstr ""
38
39 #: includes/admin/class-admin-init.php:189
40 msgid "View On Github"
41 msgstr ""
42
43 #: includes/admin/class-admin-init.php:190
44 msgid "Report Issue"
45 msgstr ""
46
47 #: includes/admin/class-admin-init.php:191
48 msgid "Donate"
49 msgstr ""
50
51 #: includes/admin/class-admin-init.php:192
52 msgid "Contact Author"
53 msgstr ""
54
55 #: includes/admin/class-ajax-handler.php:29
56 #: includes/admin/class-ajax-handler.php:46
57 #: includes/admin/class-ajax-handler.php:50
58 msgid "Invalid Product ID"
59 msgstr ""
60
61 #: includes/admin/class-ajax-handler.php:41
62 msgid "Success"
63 msgstr ""
64
65 #: includes/admin/class-ajax-handler.php:87
66 msgid "Unable To Process Your Request Please Try Again later"
67 msgstr ""
68
69 #: includes/admin/class-metabox.php:10
70 msgid "Role Based Price For WooCommerce Editor"
71 msgstr ""
72
73 #: includes/admin/class-metabox.php:126
74 msgid "Variations"
75 msgstr ""
76
77 #: includes/admin/class-metabox.php:154
78 msgid "Select A Variation : "
79 msgstr ""
80
81 #: includes/admin/class-metabox.php:205
82 msgid "Clear Cache"
83 msgstr ""
84
85 #: includes/admin/class-metabox.php:211
86 msgid "Save Price"
87 msgstr ""
88
89 #: includes/admin/class-metabox.php:228
90 msgid "WC Product Price : "
91 msgstr ""
92
93 #: includes/admin/class-price-editor-fields.php:24
94 #: includes/admin/settings_framework/class-wp-plugin-options.php:23
95 #: includes/admin/settings_framework/class-wp-plugin-options.php:34
96 msgid "General"
97 msgstr ""
98
99 #: includes/admin/class-price-editor-fields.php:36
100 msgid "Enable Role Based Pricing"
101 msgstr ""
102
103 #: includes/admin/class-price-editor-fields.php:63
104 msgid "Enter Product's "
105 msgstr ""
106
107 #: includes/admin/class-product-functions.php:29
108 msgid "Product Price Updated."
109 msgstr ""
110
111 #: includes/admin/class-product-functions.php:31
112 msgid "Price Not Defined. Please Try Again"
113 msgstr ""
114
115 #: includes/admin/settings_framework/class-wp-plugin-options.php:27
116 msgid "Extensions Options"
117 msgstr ""
118
119 #: includes/admin/settings_framework/class-wp-plugin-options.php:29
120 msgid "Extensions"
121 msgstr ""
122
123 #: includes/admin/settings_framework/class-wp-plugin-options.php:39
124 msgid "No Addons Activated / Installed."
125 msgstr ""
126
127 #: includes/admin/settings_framework/class-wp-plugin-options.php:55
128 msgid "Allowed User Roles"
129 msgstr ""
130
131 #: includes/admin/settings_framework/class-wp-plugin-options.php:56
132 msgid "User Roles To List In Product Edit Page"
133 msgstr ""
134
135 #: includes/admin/settings_framework/class-wp-plugin-options.php:69
136 msgid "Allowed Product Pricing"
137 msgstr ""
138
139 #: includes/admin/settings_framework/class-wp-plugin-options.php:70
140 msgid "Price Fields To List In Product Edit Page"
141 msgstr ""
142
143 #: includes/admin/settings_framework/class-wp-plugin-options.php:85
144 msgid " Label "
145 msgstr ""
146
147 #: includes/admin/settings_framework/class-wp-plugin-options.php:97
148 msgid "WPML Integration"
149 msgstr ""
150
151 #: includes/admin/settings_framework/class-wp-plugin-options.php:98
152 msgid "check if you have installed wpml and the price are showing wrong. "
153 msgstr ""
154
155 #: includes/admin/settings_framework/class-wp-settings-framework.php:78
156 msgid "Role Based Price Settings"
157 msgstr ""
158
159 #: includes/admin/views/addons-single.php:21
160 msgid "V"
161 msgstr ""
162
163 #: includes/admin/views/addons-single.php:31
164 msgid "By"
165 msgstr ""
166
167 #: includes/admin/views/addons-single.php:40
168 msgid "Required Plugins :"
169 msgstr ""
170
171 #: includes/admin/views/addons-single.php:46 includes/class-extensions.php:214
172 msgid "InActive"
173 msgstr ""
174
175 #: includes/admin/views/addons-single.php:49
176 msgid "Plugin Does Not Exist"
177 msgstr ""
178
179 #: includes/admin/views/addons-single.php:52 includes/class-extensions.php:213
180 msgid "Active"
181 msgstr ""
182
183 #: includes/admin/views/addons-single.php:74
184 msgid "Screenshots"
185 msgstr ""
186
187 #: includes/admin/views/addons-single.php:89
188 msgid "Addon Slug : "
189 msgstr ""
190
191 #: includes/admin/views/addons-single.php:95
192 msgid "Last Updated:"
193 msgstr ""
194
195 #: includes/admin/views/ajax-modal-footer.php:4
196 msgid "Close"
197 msgstr ""
198
199 #: includes/admin/views/ajax-modal-footer.php:6
200 msgid "Update Price"
201 msgstr ""
202
203 #: includes/admin/views/ajax-modal-header.php:3
204 msgid "Role Based Price Editor"
205 msgstr ""
206
207 #: includes/admin/views/plugin-welcome-page.php:2
208 msgid "Welcome To"
209 msgstr ""
210
211 #: includes/admin/views/plugin-welcome-page.php:3
212 #: plugins/wc-product-importer/wc-product-importer.php:79
213 msgid "Role Based Price For WooCommerce"
214 msgstr ""
215
216 #: includes/admin/views/plugin-welcome-page.php:6
217 msgid " now with improved speed and stability"
218 msgstr ""
219
220 #: includes/class-extensions.php:212
221 msgid "All"
222 msgstr ""
223
224 #: includes/class-extensions.php:228
225 msgid "Search Addons"
226 msgstr ""
227
228 #: includes/class-extensions.php:277 includes/class-extensions.php:312
229 msgid "Unable to process you request. please try again later"
230 msgstr ""
231
232 #: includes/class-extensions.php:279 includes/class-extensions.php:285
233 msgid "Unable To De-Activate Addon. Please Try Again Later"
234 msgstr ""
235
236 #: includes/class-extensions.php:281
237 msgid "Addon De-Activated"
238 msgstr ""
239
240 #: includes/class-extensions.php:283
241 msgid "Addon Already De-Activated"
242 msgstr ""
243
244 #: includes/class-extensions.php:314 includes/class-extensions.php:320
245 msgid "Unable To Activate Addon. Please Try Again Later"
246 msgstr ""
247
248 #: includes/class-extensions.php:316
249 msgid "Addon Activated"
250 msgstr ""
251
252 #: includes/class-extensions.php:318
253 msgid "Addon Already Activated"
254 msgstr ""
255
256 #: includes/class-extensions.php:329
257 msgid "Activate"
258 msgstr ""
259
260 #: includes/class-extensions.php:330
261 msgid "Deactivate"
262 msgstr ""
263
264 #: includes/class-product-pricing.php:484
265 #: includes/class-product-pricing.php:494
266 msgctxt "Price range: from - to"
267 msgid " % 1$s & ndash;%2$s"
268 msgstr ""
269
270 #: includes/class-product-pricing.php:498
271 msgid "Free! "
272 msgstr ""
273
274 #: includes/class-shortcode-handler.php:47
275 msgid "Invalid Product ID Given"
276 msgstr ""
277
278 #: includes/class-shortcode-handler.php:53
279 msgid "Invalid User Role Given"
280 msgstr ""
281
282 #: includes/class-shortcode-handler.php:61
283 msgid "Invalid Price Type Given"
284 msgstr ""
285
286 #: includes/functions.php:132
287 msgid "Visitor / LogedOut User"
288 msgstr ""
289
290 #: includes/functions.php:230
291 msgid "Regular Price"
292 msgstr ""
293
294 #: includes/functions.php:231
295 msgid "Selling Price"
296 msgstr ""
297
298 #: includes/helpers/class-activator.php:32
299 msgid "Thank you for installing <strong>Role Based Price For WooCommerce</strong> : <strong>Version 3.0 </strong>"
300 msgstr ""
301
302 #: includes/helpers/class-activator.php:33
303 msgid "We have worked entire 1 year to improve our plugin to best of our ability and we hope you will enjoy working with it. We are always open for your sugestions and feature requests"
304 msgstr ""
305
306 #: includes/helpers/class-activator.php:36
307 msgid "If you have installed <strong>WPRB</strong> for the 1st time or upgrading from <strong> Version 2.8.7</strong> then you will need to update its' settings once again or this plugin will not function properly. "
308 msgstr ""
309
310 #: includes/helpers/class-activator.php:39
311 msgid "Click Here to update the settings"
312 msgstr ""
313
314 #: plugins/aelia-currencyswitcher-integration/aelia-currencyswitcher-integration.php:82
315 #: plugins/aelia-currencyswitcher-integration/wc_rbp_fields.php:3
316 msgid "Aelia Currency Switcher"
317 msgstr ""
318
319 #: plugins/aelia-currencyswitcher-integration/aelia-currencyswitcher-integration.php:93
320 msgid "Allowed Currency"
321 msgstr ""
322
323 #: plugins/aelia-currencyswitcher-integration/aelia-currencyswitcher-integration.php:94
324 msgid "Allowed Currency To Show In Role Based Price Listing"
325 msgstr ""
326
327 #: plugins/aelia-currencyswitcher-integration/wc_rbp_fields.php:23
328 msgid "Enter Product's %s For %s Currency"
329 msgstr ""
330
331 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:78
332 msgid "Hide Price For"
333 msgstr ""
334
335 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:79
336 msgid "Product Price will be hidden for the selected user roles"
337 msgstr ""
338
339 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:91
340 msgid "Hide Add To Cart Button"
341 msgstr ""
342
343 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:92
344 msgid "Product Add To Cart Button will be hidden for the selected user roles"
345 msgstr ""
346
347 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:103
348 msgid "Hide Product Variations"
349 msgstr ""
350
351 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:104
352 msgid "if checked Variable product variation will be hidden from product page "
353 msgstr ""
354
355 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:114
356 msgid "Custom Message"
357 msgstr ""
358
359 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:115
360 msgid "Used when product price is hidden.. use <code>[currency]</code> to get current store currency"
361 msgstr ""
362
363 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:125
364 msgid "Price & AddToCart Visibility"
365 msgstr ""
366
367 #: plugins/price-add-to-cart-visibility/price-add-to-cart-visibility.php:126
368 msgid "Hide Product Price & Add To Cart button based on users role and set custom messsage to show if price is hidden"
369 msgstr ""
370
371 #: plugins/wc-product-exporter/wc-product-exporter.php:119
372 msgid "Role Based Price For WooCommerce All"
373 msgstr ""
374
375 #: plugins/wc-product-exporter/wc-product-exporter.php:123
376 msgid "WC RBP Status"
377 msgstr ""
378
379 #: plugins/wc-product-exporter/wc-product-exporter.php:127
380 msgid "WC Role Based "
381 msgstr ""
382
383 #: plugins/wc-product-exporter/wc-product-exporter.php:127
384 msgid " Price "
385 msgstr ""
386
387 #: plugins/wc-product-importer/wc-product-importer.php:62
388 #: plugins/wc-product-importer/wc-product-importer.php:63
389 msgid "Price Status"
390 msgstr ""
391 #. Plugin Name of the plugin/theme
392 msgid "Role Based Price For WooCommerce"
393 msgstr ""
394
395 #. Plugin URI of the plugin/theme
396 msgid "https://wordpress.org/plugins/woocommerce-role-based-price/"
397 msgstr ""
398
399 #. Description of the plugin/theme
400 msgid "Sell product in different price for different user role based on your settings."
401 msgstr ""
402
403 #. Author of the plugin/theme
404 msgid "Varun Sridharan"
405 msgstr ""
406
407 #. Author URI of the plugin/theme
408 msgid "http://varunsridharan.in"
409 msgstr ""
1 <?php
2 /**
3 * Plugin Name: Aelia Currency Switcher Integration
4 * Plugin URI:
5 * Version: 1.0
6 * Description: Works With Aelia Currency Switcher Integration And Allows you to set product's role based price on currency based
7 * Author: Varun Sridharan
8 * Author URI: http://varunsridharan.in
9 * Created: 2016-03-04
10 * Last Update: 2017-03-23
11 * Required Plugins: [ Name : Aelia Currency Switcher for WooCommerce | URL : http://aelia.co/shop/currency-switcher-woocommerce/ | Version : 3.8.2 | Slug : woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php]
12 * Category:Integration,Currency Switcher
13 */
14 if( ! defined('WC_RBP_PLUGIN') ) {
15 die;
16 }
17
18 if( ! class_exists('WC_Aelia_CurrencySwitcher') ) {
19 return;
20 }
21
22 require_once( __DIR__ . '/functions.php' );
23
24 class Aelia_Currency_Switcher_Integration_WC_RBP {
25 public function __construct() {
26 $this->ss_id = 'aeliacurrencyswitcher_integration';
27 $this->field_slug = 'wc_rbp_acs';
28 add_filter('wc_rbp_addon_sections', array( $this, 'add_settings_section' ));
29 add_filter('wc_rbp_addon_fields', array( $this, 'add_fields' ));
30 add_action('wc_rbp_init', array( $this, 'render' ));
31 add_action('wc_rbp_addon_styles', array( $this, 'add_style' ));
32 add_action('wc_rbp_product_save_default', array( $this, 'save_product_price' ));
33 add_action('wc_rbp_product_class_attribute', array( $this, 'add_acs_price_data_simple' ));
34 add_action('wc_rbp_product_price_value', array( $this, 'change_wc_rbp_price' ), 50, 6);
35 add_filter('wc_rbp_product_price', array( $this, 'change_wc_rbp_product_price' ), 10, 20);
36 if( wc_rbp_is_request('frontend') ) {
37 add_filter('wc_aelia_currencyswitcher_product_currency_prices', array( $this, 'my_custom_prices' ), 15, 3);
38 }
39 }
40
41 public function add_acs_price_data_simple(&$product) {
42 $product->wc_rbp_acs = wc_rbp_get_acs_product_price($product->ID);
43 }
44
45 public function add_style() {
46 echo '.acs_popup_section .wc_rbp_acs_tabs_container { padding-left: 5px; padding-right: 5px !important; }';
47 }
48
49 public function save_product_price($posted_values) {
50 if( ! isset($posted_values[$this->field_slug]) ) {
51 return;
52 }
53 $product_id = $posted_values['product_id'];
54 $wc_rbp_acs_values = $posted_values[$this->field_slug];
55 wc_rbp_update_acs_role_based_price($product_id, $wc_rbp_acs_values);
56 }
57
58 public function render() {
59 $this->base_currency = get_option('woocommerce_currency');
60 $allowed_roles = wc_rbp_allowed_roles();
61 foreach( $allowed_roles as $role ) {
62 add_action('wc_rbp_price_edit_tab_' . $role . '_after', array( $this, 'render_fields' ), 10, 4);
63 }
64 }
65
66 public function render_fields($post_id, $prodType, $prod, $tab_id) {
67 $product_id = $post_id;
68 $allowed_currency = wc_rbp_option('acs_allowed_currencies');
69 $allowed_price = wc_rbp_allowed_price();
70 $ex_price = wc_rbp_price_types();
71 if( empty($allowed_currency) ) {
72 $allowed_currency = $this->get_enabled_currencies();
73 }
74 include( __DIR__ . '/wc_rbp_fields.php' );
75 }
76
77 private function get_enabled_currencies() {
78 return apply_filters('wc_aelia_cs_enabled_currencies', array( get_option('woocommerce_currency') ));
79 }
80
81 public function add_settings_section($section) {
82 $section[] = array(
83 'id' => 'aeliacurrencyswitcher_integration',
84 'title' => __('Aelia Currency Switcher', WC_RBP_TXT),
85 'desc' => '',
86 );
87 return $section;
88 }
89
90 public function add_fields($fields) {
91 $fields[$this->ss_id][] = array(
92 'id' => WC_RBP_DB . 'acs_allowed_currencies',
93 'multiple' => 'true',
94 'type' => 'select',
95 'label' => __('Allowed Currency', WC_RBP_TXT),
96 'desc' => __('Allowed Currency To Show In Role Based Price Listing', WC_RBP_TXT),
97 'options' => $this->get_currency_key_val(),
98 'attr' => array(
99 'class' => 'wc-rbp-enhanced-select',
100 'multiple' => 'multiple',
101 ),
102 );
103 return $fields;
104 }
105
106 private function get_currency_key_val() {
107 $wc_currencies = get_woocommerce_currencies();
108 $enabled_currency = $this->get_enabled_currencies();
109 $return_currency = array();
110 foreach( $enabled_currency as $curr ) {
111 if( isset($wc_currencies[$curr]) ) {
112 $symbol = get_woocommerce_currency_symbol($curr);
113 $symbol = ! empty($symbol) ? ' [ ' . $symbol . ' ] ' : '';
114 $return_currency[$curr] = $wc_currencies[$curr] . $symbol;
115 }
116 }
117 return $return_currency;
118 }
119
120 public function change_wc_rbp_price($return, $price, $product_id, $product, $price_meta_key, $current_user) {
121 $status = product_rbp_status($product_id, $product);
122 if( ! $status ) {
123 return $return;
124 }
125
126 if( empty($current_user) ) {
127 $current_user = wc_rbp_get_current_user();
128 }
129 return $this->get_acs_role_price($return, $product_id, $current_user, $price_meta_key);
130 }
131
132
133 public function get_acs_role_price($return, $product_id, $userrole, $price_meta_key = 'regular_price', $from_currency = NULL, $to_currency = NULL) {
134
135
136 $allowed_price = wc_rbp_allowed_price();
137 $allowed_roles = wc_rbp_allowed_roles();
138
139 if( in_array($userrole, $allowed_roles) ) {
140
141 if( in_array($price_meta_key, $allowed_price) ) {
142 $send_currency = array();
143 $allowed_currency = wc_rbp_option('acs_allowed_currencies');
144
145 if( empty($allowed_currency) ) {
146 $allowed_currency = $this->get_enabled_currencies();
147 }
148 if( empty($from_currency) ) {
149 $from_currency = get_option('woocommerce_currency');
150 }
151 if( empty($to_currency) ) {
152 $to_currency = get_woocommerce_currency();
153 }
154
155 $wc_rbp_status = product_rbp_status($product_id, NULL);
156
157 if( ! $wc_rbp_status ) {
158 return $return;
159 }
160
161
162 if( $this->base_currency == $to_currency ) {
163 $price = wc_rbp_price($product_id, $userrole, $price_meta_key);
164 if( ! empty($price) ) {
165 return $price;
166 }
167 } else {
168 $rbp_price = wc_rbp_acs_price($product_id, $userrole, $to_currency, 'currency');
169 $price = '';
170 $opposite_key = 'selling_price';
171 if( $price_meta_key == 'selling_price' ) {
172 $opposite_key = 'regular_price';
173 }
174
175
176 if( isset($rbp_price[$price_meta_key]) && isset($rbp_price[$opposite_key]) ) {
177 if( $rbp_price[$price_meta_key] == "" && $rbp_price[$opposite_key] == "" ) {
178 $price = $return;
179 } else if( $rbp_price[$price_meta_key] == "" && $rbp_price[$opposite_key] != "" ) {
180 $price = $rbp_price[$opposite_key];
181 } else if( $rbp_price[$price_meta_key] != "" && $rbp_price[$opposite_key] == "" ) {
182 $price = $rbp_price[$price_meta_key];
183 } else if( $rbp_price[$price_meta_key] != "" ) {
184 $price = $rbp_price[$price_meta_key];
185 }
186 } else if( isset($rbp_price[$price_meta_key]) && ! isset($rbp_price[$opposite_key]) ) {
187 if( $rbp_price[$price_meta_key] == "" ) {
188 $price = $base_price;
189 } else if( $rbp_price[$price_meta_key] != "" ) {
190 $price = $rbp_price[$price_meta_key];
191 }
192 } else if( isset($rbp_price[$opposite_key]) && ! isset($rbp_price[$price_meta_key]) ) {
193 if( $rbp_price[$opposite_key] == "" ) {
194 $price = $base_price;
195 } else if( $rbp_price[$opposite_key] != "" ) {
196 $price = $rbp_price[$opposite_key];
197 }
198 }
199
200 return $price;
201 }
202 } else {
203 $price_meta_key = wc_rbp_get_oppo_metakey($price_meta_key);
204 $price = $this->get_acs_role_price($return, $product_id, $userrole, $price_meta_key, $from_currency, $to_currency);
205 if( ! empty($price) ) {
206 return $price;
207 }
208 }
209 } else {
210 $this->hook_function_disableenable(TRUE);
211
212
213 $product = new WC_Product($product_id);
214 if( $price_meta_key == 'regular_price' ) {
215 $return = $product->get_regular_price();
216 }
217 if( $price_meta_key == 'selling_price' ) {
218 $return = $product->get_sale_price();
219 }
220
221 $this->hook_function_disableenable(FALSE);
222 }
223
224 return apply_filters('wc_aelia_cs_convert', $return, $from_currency, $to_currency);
225 }
226
227 public function hook_function_disableenable($disable = FALSE) {
228 if( $disable ) {
229 add_filter('role_based_price_status', array( $this, 'disable_rbp_price' ));
230 } else {
231 remove_filter('role_based_price_status', array( $this, 'disable_rbp_price' ));
232 }
233 }
234
235 public function disable_rbp_price() {
236 return FALSE;
237 }
238
239 public function change_wc_rbp_product_price($return, $role, $price, $post_id, $args) {
240 if( ! isset($args['currency']) ) {
241 return $return;
242 }
243 $allowed_price = wc_rbp_allowed_price();
244 if( $role == 'all' && $price == 'all' ) {
245 $allowed_roles = wc_rbp_allowed_roles();
246 foreach( $allowed_roles as $aroles ) {
247 foreach( $allowed_price as $aprice ) {
248 $return[$aroles][$aprice] = $this->get_acs_role_price($return[$aroles][$aprice], $post_id, $aroles, $aprice, NULL, $args['currency']);
249 }
250 }
251 } else if( $role != 'all' && $price == 'all' ) {
252 foreach( $allowed_price as $aprice ) {
253 $return[$aprice] = $this->get_acs_role_price($return[$aprice], $post_id, $role, $aprice, NULL, $args['currency']);
254 }
255 } else {
256 if( in_array($type, $allowed_price) ) {
257 $return = $this->get_acs_role_price($return, $post_id, $role, $price, NULL, $args['currency']);
258 } else {
259 $price = wc_rbp_get_oppo_metakey($price);
260 $return = $this->get_acs_role_price($return, $post_id, $role, $price, NULL, $args['currency']);
261 }
262
263 }
264 return $return;
265 }
266
267 /**
268 * Replaces the product prices with custom ones.
269 *
270 * @param array product_prices An array of product prices.
271 * @param int product_id The product ID.
272 * @param int price_type The price types to be replaced (e.g. regular prices, sale prices, etc).
273 *
274 * @return array An array of currency => price entries
275 * @author Aelia <support@aelia.co>
276 * @link http://aelia.co/about
277 */
278 public function my_custom_prices($product_prices, $product_id, $price_type) {
279 /*
280 $price_type can have one of the following values:
281 - '_regular_currency_prices' -> Product's regular prices
282 - '_sale_currency_prices' -> Product's sale prices
283 - 'variable_regular_currency_prices' -> Variation's regular prices
284 - 'variable_sale_currency_prices' -> Variation's simple prices
285 Using $price_type, load the appropriate prices (regular or sale), and store
286 them in an array, using the currency as the key. If you don't have one of the
287 prices (e.g. GBP), don't add it to the array. Example:
288 */
289
290 $status = product_rbp_status($product_id, NULL);
291 if( ! $status ) {
292 return $product_prices;
293 }
294 $type = "selling_price";
295 $price = '';
296 $allowed_currency = wc_rbp_option('acs_allowed_currencies');
297 $allowed_price = wc_rbp_allowed_price();
298 $current_user = wc_rbp_get_current_user();
299 $send_currency = array();
300 if( empty($allowed_currency) ) {
301 $allowed_currency = $this->get_enabled_currencies();
302 }
303 if( $price_type == 'variable_regular_currency_prices' || $price_type == '_regular_currency_prices' ) {
304 $type = "regular_price";
305 }
306
307
308 $allowed_roles = wc_rbp_allowed_roles();
309
310 if( in_array($current_user, $allowed_roles) ) {
311 if( ! in_array($type, $allowed_price) ) {
312 $send_currency = array();
313 } else {
314 foreach( $allowed_currency as $currency ) {
315 if( $this->base_currency == $currency ) {
316 $price = wc_rbp_price($product_id, $current_user, $type);
317 if( $price !== FALSE ) {
318 if( ! empty($price) )
319 $send_currency[$currency] = $price;
320 }
321 } else {
322 $price = wc_rbp_acs_price($product_id, $current_user, $currency, $type);
323 $send_currency[$currency] = $price;
324 }
325
326 }
327 }
328 }
329
330 $product_prices = array_merge($product_prices, $send_currency);
331 return $product_prices;
332 }
333 }
334
335 return new Aelia_Currency_Switcher_Integration_WC_RBP;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 if( ! function_exists('wc_rbp_update_acs_role_based_price') ) {
4 /**
5 * Updates Products Role Based Price Array In DB
6 *
7 * @param int $post_id Post ID To Update
8 * @param array $price_array Price List
9 *
10 * @return boolean [[Description]]
11 */
12 function wc_rbp_update_acs_role_based_price($post_id, $price_array) {
13 update_post_meta($post_id, '_acs_role_based_price', $price_array);
14 return TRUE;
15 }
16 }
17
18 if( ! function_exists('wc_rbp_get_acs_product_price') ) {
19
20 /**
21 * Gets Product price from DB
22 * #TODO Integrate Wth product_rbp_price function to make it faster
23 */
24 function wc_rbp_get_acs_product_price($post_id, $supress_filter = FALSE) {
25 $price = get_post_meta($post_id, '_acs_role_based_price');
26
27 if( ! empty($price) ) {
28 $price = $price[0];
29 } else if( empty($price) ) {
30 $price = array();
31 }
32 if( ! $supress_filter )
33 $price = apply_filters('wc_rbp_product_acs_prices', $price);
34
35 return $price;
36 }
37
38 }
39
40 if( ! function_exists('product_acs_rbp_price') ) {
41 /**
42 * Gets product price from DB
43 */
44 function product_acs_rbp_price($post_id) {
45 $price = wc_rbp_product_variable($post_id, 'wc_rbp_acs', 'wc_rbp_get_acs_product_price');
46 return $price;
47 }
48 }
49
50 if( ! function_exists('wc_rbp_acs_price') ) {
51 /**
52 * Returns Price Based On Give Value
53 *
54 * @role : enter role slug / use all to get all roles values
55 * @price : use selling_price / regular_price or use all to get all values for the given role
56 */
57 function wc_rbp_acs_price($post_id, $role, $currency, $price = 'regular_price', $args = array()) {
58 $dbprice = product_acs_rbp_price($post_id);
59
60 $return = FALSE;
61
62 if( $price == 'all' && $role == 'all' ) {
63 $return = $dbprice;
64 } else if( $price == 'all' && $role !== 'all' ) {
65 if( isset($dbprice[$role]) ) {
66 $return = $dbprice[$role];
67 }
68 } else if( $price == 'currency' && $role !== 'all' ) {
69 if( isset($dbprice[$role]) ) {
70 $return = $dbprice[$role][$currency];
71 }
72 } else if( isset($dbprice[$role][$currency][$price]) ) {
73 $return = $dbprice[$role][$currency][$price];
74 }
75
76
77 $return = apply_filters('wc_rbp_product_acs_price', $return, $role, $price, $post_id, $args);
78
79 return $return;
80 }
81 }
...\ No newline at end of file ...\ No newline at end of file
1 <div class="wc_rbp_popup_section acs_popup_section">
2
3 <div class="wc_rbp_pop_field"><h3><?php _e('Aelia Currency Switcher', WC_RBP_TXT); ?></h3></div>
4
5 <div class="wc_rbp_pop_field">
6 <?php
7 $tabs = array();
8 $content = array();
9 $output_html = '';
10
11 foreach( $allowed_currency as $currency ) {
12 if( $this->base_currency == $currency ) {
13 continue;
14 }
15 $symbol = get_woocommerce_currency_symbol($currency);
16 $symbol = ! empty($symbol) ? ' (' . $symbol . ') ' : ' (' . $currency . ') ';
17
18 $tabs[$tab_id . '-' . $currency] = array( 'title' => $currency . ' ' . $symbol );
19
20 $output_html = '<div class="wc_rbp_price_container wc_rbp_popup_section wc_rbp_popup_section_' . $tab_id . '_' . $currency . '">';
21 foreach( $allowed_price as $price ) {
22 $value = wc_rbp_acs_price($product_id, $tab_id, $currency, $price);
23 $text = __('Enter Product\'s %s For %s Currency', WC_RBP_TXT);
24 $field_id = 'wc_rbp_acs[' . $tab_id . '][' . $currency . '][' . $price . ']';
25 $defaults = array(
26 'type' => 'text',
27 'label' => $ex_price[$price] . $symbol,
28 'description' => sprintf($text, $ex_price[$price], $currency),
29 'class' => array(),
30 'label_class' => array(),
31 'input_class' => array( 'wc_input_price', $price, 'wc_rbp_' . $price ),
32 'return' => TRUE,
33 'custom_attributes' => array(),
34 );
35
36 $output_html .= '<div class="wc_rbp_pop_field_50 wc_rbp_pop_field_' . $price . '">';
37 $output_html .= woocommerce_form_field($field_id, $defaults, $value);
38 $output_html .= '</div>';
39
40 }
41 $output_html .= '</div>';
42 $content[$tab_id . '-' . $currency] = $output_html;
43 }
44
45 echo wc_rbp_generate_tabs($tabs, $content, array( 'tab_style' => 'default' ));
46 ?>
47 </div>
48
49 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Plugin Name: Price & Add To Cart Visibility
4 * Plugin URI:
5 * Version: 1.0
6 * Description: Allows to hide products price & add to cart button based on the user roles.
7 * Author: Varun Sridharan
8 * Author URI: http://varunsridharan.in
9 * Last Update: 2016-03-04
10 * Category: Tools
11 */
12
13
14 if( ! defined('WC_RBP_PLUGIN') ) {
15 die;
16 }
17
18 class Price_add_to_cart_visibility_WC_RBP {
19
20 public function __construct() {
21 add_filter('wc_rbp_addon_sections', array( $this, 'add_settings_section' ));
22 add_filter('wc_rbp_addon_fields', array( $this, 'add_settings_fields' ));
23 add_filter('init', array( $this, 'check_remove_add_to_cart' ), 999);
24 add_filter('woocommerce_get_price_html', array( $this, 'remove_price' ), 999, 2);
25 }
26
27
28 public function check_remove_add_to_cart() {
29 $current_role = wc_rbp_get_current_user();
30 $resticted_role = wc_rbp_option('hide_product_addtocart');
31 $variable_status = wc_rbp_option('hide_variable_product');
32
33 if( empty($resticted_role) ) {
34 return;
35 }
36 if( in_array($current_role, $resticted_role) ) {
37 add_filter('woocommerce_loop_add_to_cart_link', array( &$this, 'remove_add_to_cart_link' ), 99);
38 remove_action('woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30);
39 if( $variable_status ) {
40 remove_action('woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30);
41 } else {
42 remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20);
43 }
44 }
45 }
46
47 public function remove_add_to_cart_link($link) {
48 return '';
49 }
50
51
52 public function remove_price($price) {
53 $current_role = wc_rbp_get_current_user();
54 $resticted_role = wc_rbp_option('hide_product_price');
55
56 if( ! empty($resticted_role) ) {
57 if( in_array($current_role, $resticted_role) ) {
58 $price_notice = wc_rbp_option('pv_custom_message');
59 $price_notice = apply_filters('wc_rbp_price_visibility_custom_price_message', $price_notice, $current_role);
60 if( ! empty($price_notice) ) {
61 $symbol = get_woocommerce_currency_symbol();
62 $price_notice = str_replace('[currency]', $symbol, $price_notice);
63 return $price_notice;
64 }
65 return '';
66 }
67 }
68
69 return $price;
70 }
71
72
73 public function add_settings_fields($fields) {
74 $fields['price_visibility'][] = array(
75 'id' => WC_RBP_DB . 'hide_product_price',
76 'multiple' => 'true',
77 'type' => 'select',
78 'label' => __('Hide Price For', WC_RBP_TXT),
79 'desc' => __('Product Price will be hidden for the selected user roles', WC_RBP_TXT),
80 'options' => wc_rbp_get_user_roles_selectbox(),
81 'attr' => array(
82 'class' => 'wc-rbp-enhanced-select',
83 'multiple' => 'multiple',
84 ),
85 );
86
87 $fields['price_visibility'][] = array(
88 'id' => WC_RBP_DB . 'hide_product_addtocart',
89 'multiple' => 'true',
90 'type' => 'select',
91 'label' => __('Hide Add To Cart Button', WC_RBP_TXT),
92 'desc' => __('Product Add To Cart Button will be hidden for the selected user roles', WC_RBP_TXT),
93 'options' => wc_rbp_get_user_roles_selectbox(),
94 'attr' => array(
95 'class' => 'wc-rbp-enhanced-select',
96 'multiple' => 'multiple',
97 ),
98 );
99
100 $fields['price_visibility'][] = array(
101 'id' => WC_RBP_DB . 'hide_variable_product',
102 'type' => 'checkbox',
103 'label' => __('Hide Product Variations', WC_RBP_TXT),
104 'desc' => __('if checked Variable product variation will be hidden from product page ', WC_RBP_TXT),
105 'attr' => array( 'class' => 'wc_rbp_checkbox', ),
106 );
107
108
109 $fields['price_visibility'][] = array(
110 'id' => WC_RBP_DB . 'pv_custom_message',
111 'value' => html_entity_decode(wc_rbp_option('pv_custom_message')),
112 'type' => 'richtext',
113 'richtext_settings' => array( 'textarea_rows' => 5 ),
114 'label' => __('Custom Message', WC_RBP_TXT),
115 'desc' => __('Used when product price is hidden.. use <code>[currency]</code> to get current store currency', WC_RBP_TXT),
116 'attr' => array( 'class' => 'wc_rbp_checkbox', ),
117 );
118
119 return $fields;
120 }
121
122 public function add_settings_section($section) {
123 $c_section = array();
124 $c_section['id'] = 'price_visibility';
125 $c_section['title'] = __('Price & AddToCart Visibility', WC_RBP_TXT);
126 $c_section['desc'] = __('Hide Product Price & Add To Cart button based on users role and set custom messsage to show if price is hidden', WC_RBP_TXT);
127 $section[] = $c_section;
128 return $section;
129 }
130
131 }
132
133 return new Price_add_to_cart_visibility_WC_RBP;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Plugin Name: WooCommerce Product Export
4 * Plugin URI:
5 * Version: 1.0
6 * Description: This Addon Integration With Default Product Exporter In WooCommerce And Provides Options To Export Role Based Prices
7 * Author: Varun Sridharan
8 * Author URI: http://varunsridharan.in
9 * Last Update: 2017-07-07
10 * Category: Tools,Price Export
11 */
12
13 if( ! defined('WC_RBP_PLUGIN') ) {
14 die;
15 }
16
17 class wc_product_price_exporter {
18
19 public function __construct() {
20 $this->is_wcrbp_export = FALSE;
21 $this->key_vals();
22 add_filter("woocommerce_product_export_product_default_columns", array( $this, 'add_option' ));
23 add_filter("woocommerce_product_export_row_data", array( $this, 'add_wcrbp_prices' ), 1, 2);
24 add_action("wp_ajax_woocommerce_do_ajax_product_export", array( $this, 'check_wcrbp_export' ), 1);
25 }
26
27 public function key_vals() {
28 $allowed_user_roles = wc_rbp_allowed_roles();
29 $allowed_prices = wc_rbp_allowed_price();
30 $active_cols = array( 'wcrbp_status' => '' );
31 $user_roles = array();
32 foreach( $allowed_user_roles as $role_id ) {
33 if( ! isset($user_roles['wcrbp_' . $role_id]) ) {
34 $user_roles['wcrbp_' . $role_id] = array();
35 }
36 foreach( $allowed_prices as $price_id ) {
37 if( ! isset($active_cols['wcrbp_' . $role_id . '_' . $price_id]) ) {
38 $user_roles['wcrbp_' . $role_id]['wcrbp_' . $role_id . '_' . $price_id] = '';
39 $active_cols['wcrbp_' . $role_id . '_' . $price_id] = array( 'role' => $role_id,
40 'price' => $price_id,
41 );
42 }
43 }
44 }
45
46 $this->active_cols = $active_cols;
47 $this->user_roles = $user_roles;
48 return $this->active_cols;
49 }
50
51 public function check_wcrbp_export() {
52
53 if( isset($_POST['selected_columns']) ) {
54 if( is_array($_POST['selected_columns']) ) {
55 if( in_array('wcrbp_price', $_POST['selected_columns']) ) {
56 $this->remove_post_data('wcrbp_price');
57 $_POST['selected_columns'] = array_merge($_POST['selected_columns'], array_keys($this->key_vals()));
58 $this->is_wcrbp_export = TRUE;
59
60 } else {
61 foreach( array_keys($this->user_roles) as $role ) {
62 if( in_array($role, $_POST['selected_columns']) ) {
63 $this->remove_post_data($role);
64 $_POST['selected_columns'] = array_merge($_POST['selected_columns'], array_keys($this->user_roles[$role]));
65 $this->is_wcrbp_export = TRUE;
66 }
67 }
68 }
69 }
70 }
71
72 if( $this->is_wcrbp_export ) {
73 add_filter("woocommerce_product_export_column_names", array( $this, 'custom_col' ));
74 }
75 }
76
77 public function remove_post_data($key) {
78 foreach( $_POST['selected_columns'] as $id => $vl ) {
79 if( $vl == $key ) {
80 unset($_POST['selected_columns'][$id]);
81 }
82 }
83 }
84
85 public function add_wcrbp_prices($row, $product) {
86 if( $this->is_wcrbp_export ) {
87 $prices = wc_rbp_price($product->get_id(), 'all', 'all');
88 if( isset($row['wcrbp_status']) )
89 $row['wcrbp_status'] = wc_rbp_product_status($product->get_id(), TRUE);
90
91 if( ! empty($prices) ) {
92 foreach( $prices as $user => $price_types ) {
93 foreach( $price_types as $type => $price ) {
94 if( isset($row['wcrbp_' . $user . '_' . $type]) ) {
95 $row['wcrbp_' . $user . '_' . $type] = wc_format_localized_price($price);
96 }
97 }
98 }
99 }
100 }
101
102 return $row;
103 }
104
105 public function custom_col($cols) {
106 $new_cols = $this->active_cols;
107 $allowed_user_roles = wc_rbp_allowed_roles();
108 $allowed_prices = wc_rbp_allowed_price();
109 foreach( $allowed_user_roles as $user_role_id ) {
110 foreach( $allowed_prices as $price ) {
111 if( ! isset($cols['wcrbp_' . $user_role_id . '_' . $price]) ) {
112 $cols['wcrbp_' . $user_role_id . '_' . $price] = $user_role_id . '_' . $price;
113 }
114 }
115 }
116 $cols['wcrbp_status'] = 'wcrbp_status';
117 return $cols;
118 }
119
120 public function add_option($options) {
121 $options['wcrbp_price'] = __("Role Based Price For WooCommerce All", WC_RBP_TXT);
122
123 $allowed_user_roles = wc_rbp_allowed_roles();
124 $user_roles = wc_rbp_get_wp_roles();
125 $options['wcrbp_status'] = __("WC RBP Status", WC_RBP_TXT);
126 foreach( $user_roles as $user_role_id => $user_role_name ) {
127 if( in_array($user_role_id, $allowed_user_roles) ) {
128 if( ! isset($options['wcrbp_' . $user_role_id]) ) {
129 $options['wcrbp_' . $user_role_id] = __('WC Role Based ', WC_RBP_TXT) . $user_role_name['name'] . __(' Price ', WC_RBP_TXT);
130 }
131 }
132 }
133 return $options;
134 }
135 }
136
137 return new wc_product_price_exporter;
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Plugin Name: WooCommerce Product Importer
4 * Plugin URI:
5 * Version: 1.0
6 * Description: This Addon Integration With Default Product Importer In WooCommerce And Provides Options To Import, Role Based Prices
7 * Author: Varun Sridharan
8 * Author URI: http://varunsridharan.in
9 * Last Update: 2017-07-07
10 * Category: Tools,Price Import
11 */
12
13 if( ! defined('WC_RBP_PLUGIN') ) {
14 die;
15 }
16
17 class wc_product_price_importer {
18
19 public function __construct() {
20 add_filter("woocommerce_csv_product_import_mapping_options", array( $this, 'add_import_options' ));
21 add_action("woocommerce_product_import_inserted_product_object", array( $this, 'save_price' ), 10, 2);
22 }
23
24 public function save_price($product, $data) {
25 $this->generate_options_data();
26 $obj = $this->options_product_save;
27 $obk = array_keys($obj);
28 $final_price = array();
29 $status = FALSE;
30 foreach( $data as $id => $value ) {
31 if( $id == 'wcrbp_status' ) {
32 if( $value == 'no' ) {
33 $status = FALSE;
34 } else if( $value == 'yes' ) {
35 $status = TRUE;
36 } else if( floatval($value) == 0 ) {
37 $status = FALSE;
38 } else if( floatval($value) == 1 ) {
39 $status = TRUE;
40 }
41
42 } else if( in_array($id, $obk) ) {
43 $attribute = $obj[$id];
44 $role = $attribute['role'];
45 $price_type = $attribute['price'];
46 if( $value != '' ) {
47 $final_price[$role][$price_type] = wc_format_decimal($value);
48 }
49 }
50 }
51 if( ! empty($final_price) )
52 wc_rbp_update_role_based_price($product->get_id(), $final_price);
53
54 wc_rbp_update_role_based_price_status($product->get_id(), $status);
55
56 }
57
58 public function generate_options_data() {
59 if( isset($this->options_updated) ) {
60 return $this->options_updated;
61 }
62 $allowed_user_roles = wc_rbp_allowed_roles();
63 $allowed_prices = wc_rbp_allowed_price();
64 $options = array( "wcrbp_status" => __("Price Status") );
65 $options2 = array( "wcrbp_status" => __("Price Status") );
66 foreach( wc_rbp_get_wp_roles() as $role_id => $data ) {
67 if( in_array($role_id, $allowed_user_roles) ) {
68 foreach( $allowed_prices as $price_id ) {
69 $options[$role_id . '_' . $price_id] = ' WC Role Based ' . $data['name'] . ' - ' . wc_rbp_price_types($price_id);
70 $options2[$role_id . '_' . $price_id] = array( 'role' => $role_id, 'price' => $price_id );
71 }
72 }
73 }
74 $this->options_updated = $options;
75 $this->options_product_save = $options2;
76 return $options;
77 }
78
79 public function add_import_options($options) {
80 $options['wcrbp_options'] = array(
81 'name' => __("Role Based Price For WooCommerce"),
82 'options' => $this->generate_options_data(),
83 );
84 return $options;
85 }
86 }
87
88 return new wc_product_price_importer;
...\ No newline at end of file ...\ No newline at end of file
1 === Role Based Price For WooCommerce ===
2 Contributors: varunms,arnis.arbidans
3 Author URI: http://varunsridharan.in/
4 Plugin URL: https://wordpress.org/plugins/woocommerce-role-based-price/
5 Tags: Role Based Price For WooCommerce,WooCommerce,Role based pricing,user role,wc dynamic pricing,wpallimport,wpallexport,product addons,role,selling price,regular price,sale price,selling,discounts,wordpress,ecommerce,membership discounts,membership,digital,downloads,download,drop price,dropshipper,advertising,deals,group pricing,wpml,wpml currencyswitcher,aelia currency swticher, Online Payment,Payment,Online, affiliate, cart, checkout, digital, download, downloadable, e-commerce, ecommerce, inventory, reports, sales, sell, shipping, shop, shopping, stock, store, tax, variable, widgets, woothemes, wordpress ecommerce,discounts, prices, wholesale, woocommerce,advertising, discount, marketing, Membership, price, promotion
6 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=36Y7KSYPF7KTU
7 Requires at least: 3.0
8 Tested up to: 5.2.1
9 WC requires at least: 3.0
10 WC tested up to:3.5
11 Stable tag: 3.3.6
12 License: GPLv2 or later
13 License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
15 Sell product in different price for different user role based on your settings.
16
17 == Description ==
18
19 <h3>Thanks For Your Continued Support For Role Based Price For WooCommerce</h3>
20 <p>We Are Already In A Process For Created Version 4.0 For This Plugin
21 <a href="https://forms.gle/waxC4Mm9SZFWuq3A8">Join Newsletter / Request Beta Access</a></p>
22
23 <hr/>
24
25 This plugin can make your simple WooCommerce shop in to multi currency and price level marketplace where products can be offered at different prices for different customer groups.
26 For example, Subscribers or Contributors get different prices than new customers. Differentiate your registered users to get your shop more attractive. New roles can be created and managed.
27
28
29 Latest version have been greatly improved for smoother and more speedy functioning, all user interfaces have been improved for more friendly user/webmaster experience. It is now WPML ready straight of of box.
30
31 We have added built-in plugin extension marketplace for more PRO level functions that not all might need but we think they are very useful. Please check full feature list below.
32
33 [youtube https://www.youtube.com/watch?v=rlX8okqNfs4]
34
35 We have worked on this plugin for last 3 years and so far it have been all free but in order for us to continue with this plugin development we had to move few of its’ features/extensions in to PRO(paid) version that is available for very generous price of $59 (+$20 for extended 12 month support) here: <a href="https://1.envato.market/wcrbp">WC Role Based Pricing Pro</a>
36
37
38 = Features + Add-Ons =
39 * User Friendly UI
40 * Simple , Variable / Variation , Grouped , External Product Type Supported
41 * Supports Regular & Selling Price
42 * Works With WPML
43 * Developer Friendly
44 * Easy To Create Addons
45 * Aelia Currency Switcher Integration
46 * Price & AddToCart Visiablity
47 * Shortcode to get product price
48 * Integration With WC Product Importer / Exporter
49
50 = Pro Features + Add-ons =
51 * Schedule Selling Price
52 * Dynamic Pricing
53 * Role Based Payment Gateway Blocker
54 * Role Based Product Blocker
55 * RBP temporary custom link access
56 * List Role Pricing Table
57 * WPML Currency Switcher Integration
58 * Bulk Price Updater Integration
59 * WPAllImport Integration
60
61
62 = Integration =
63 * Integration With <a href="https://woocommerce.wordpress.com/2017/06/28/woocommerce-3-1-has-landed/">WC Product Importer / Exporter</a>
64 * Integration With <a href="https://aelia.co/shop/currency-switcher-woocommerce/" > Aelia Currency Swticher </a>
65 * Integration With <a href="http://www.wpallimport.com/" > WP All Import Plugin </a>
66 * Integration With <a href="https://codecanyon.net/item/woocommerce-bulk-price-updater/14276992?ref=varunsridharan" >WC Bulk Price Updater </a>
67 * Integration With <a href="http://wpml.org/" >WPML Currency Switcher </a>
68 * Integration With <a href="https://wordpress.org/plugins/wc-frontend-manager/">WC Frontend Manager</a>
69 * Integration With <a href="https://barn2.co.uk/wordpress-plugins/woocommerce-product-table/">WC Product Table</a>
70 * Integration With <a href="https://codecanyon.net/item/improved-variable-product-attributes-for-woocommerce/9981757?ref=varunsridharan">Improved Variable Product Attributes for WooCommerce </a>
71
72 = Get Product's Regular Price With Custom User Role =
73 `[wc_rbp id='99' role='administrator' price='regular_price']`
74
75 = Get Product's Selling Price Based On Logged In User =
76 `[wc_rbp id='99' role='current' price='selling_price']`
77
78 = Get Product's Base Regular Price =
79 `[wc_rbp id='99' price='product_regular_price']`
80
81 = Get Product's Base Selling Price =
82 `[wc_rbp id='99' price='product_selling_price']`
83
84 = Get Product's Regular Price With Custom User Role =
85 `[wc_rbp id='99' role='administrator' price='regular_price']`
86
87 = Get Product's Selling Price Based On Logged In User =
88 `[wc_rbp id='99' role='current' price='selling_price']`
89
90 = Get Product's Base Regular Price =
91 `[wc_rbp id='99' price='product_regular_price']`
92
93 = Get Product's Base Selling Price =
94 `[wc_rbp id='99' price='product_selling_price']`
95
96
97 = Shortcode Variables Explained =
98 * `id=99` you need to replace the `99` with your simple/variable product id
99 * `role=administrator` you need replace `administrator` with your user role id / use `current` to get loggedin user role
100 * `price` use `regular_price` or `selling_price` to get the value of each
101
102 = Plugin Translators =
103 * <a href="https://profiles.wordpress.org/miladjef/">miladjef</a> {Persian translation}
104
105 = Plugin Contributors / Testers =
106 * <a href="https://profiles.wordpress.org/raj5harma">Raj sharma</a>
107 * <a href="https://wordpress.org/support/profile/nick6352683" >nick6352683 </a>
108 * <a href="https://profiles.wordpress.org/arnisarbidans">arnis.arbidans</a>
109 * <a href="https://profiles.wordpress.org/cuppy90">Cuppy</a>
110 * <a href="#">Joachim Keuppens</a>
111 * <a href="https://github.com/diventimage">Divent Image</a>
112 * <a href="https://github.com/gbreen">gbreen</a>
113 * <a href="https://github.com/vizulatedev">vizulatedev</a>
114 * <a href="https://profiles.wordpress.org/cloudcuckoo/">Joeyvan Dongen</a>
115 * <a href="https://profiles.wordpress.org/timmyhutton" >timmy hutton</a>
116
117 == Screenshots ==
118 1. Plugin Installed
119 2. Plugin Settings Menu
120 3. Plugin Settings Page
121 4. Free Add-ons
122 5. Paid Add-ons
123 6. Simple Product Editor
124 7. Simple Product Editor
125 8. Variable Product Editor
126 9. Aelia Currency Switcher Integration Settings
127 10. Aelia Currency Switcher Simple Product Editor
128 11. Aelia Currency Switcher Variable Product Editor
129
130 == Installation ==
131
132 = Minimum Requirements =
133
134 * WordPress 3.8 or greater
135 * PHP version 5.2.4 or greater
136 * MySQL version 5.0 or greater
137
138 = Automatic installation =
139
140 Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't need to leave your web browser. To do an automatic install of Role Based Price For WooCommerce, log in to your WordPress dashboard, navigate to the Plugins menu and click Add New.
141
142 In the search field type "Role Based Price For WooCommerce" and click Search Plugins. Once you've found our plugin you can view details about it such as the the point release, rating and description. Most importantly of course, you can install it by simply clicking "Install Now"
143
144 = Manual installation =
145
146 The manual installation method involves downloading our plugin and uploading it to your Web Server via your favourite FTP application. The WordPress codex contains [instructions on how to do this here](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).
147
148 1. Installing alternatives:
149 * via Admin Dashboard:
150 * Go to 'Plugins > Add New', search for "Role Based Price For WooCommerce", click "install"
151 * OR via direct ZIP upload:
152 * Upload the ZIP package via 'Plugins > Add New > Upload' in your WP Admin
153 * OR via FTP upload:
154 * Upload `woocommerce-role-based-price` folder to the `/wp-content/plugins/` directory
155
156 2. Activate the plugin through the 'Plugins' menu in WordPress
157
158 == Frequently Asked Questions ==
159 **Get Product's Regular Price With Custom User Role**
160 `[wc_rbp id='99' role='administrator' price='regular_price']`
161
162 **Get Product's Selling Price Based On Logged In User**
163 `[wc_rbp id='99' role='current' price='selling_price']`
164
165 **Dose This Plugin Supports Aelia Currency Switcher ?**
166
167 Yes This Plugin Support Aelia Currency Switcher. by activation of Aelia Currency Switcher In Settings Menu
168
169 **How I Can Get Support For This Plugin**
170 * http://varunsridharan.in/plugin-support/
171 * https://wordpress.org/support/plugin/woocommerce-role-based-price
172 * https://github.com/varunsridharan/WooCommerce-Role-Based-Price
173 * Email : varunsridharan23@gmail.com
174
175 **I have an idea for your plugin!**
176 That's great. We are always open to your input, and we would like to add anything we think will be useful to a lot of people. please contact us using above methods.
177
178 **I found a bug!**
179 Oops. Please Use github / WordPress to post bugs. <a href="https://github.com/varunsridharan/WooCommerce-Role-Based-Price"> Open an Issue </a>
180
181
182 **Where can I request new features**
183 Please open an issue at <a href="https://github.com/varunsridharan/WooCommerce-Role-Based-Price"> GitHub </a> and we will look into it
184
185
186 == Changelog ==
187 = 3.3.6 [19-09-2019] =
188 * Minor updates.
189
190 = 3.3.5 [29-05-2019] =
191 * Fixed : https://wordpress.org/support/topic/error-message-in-backend-2/
192
193 = 3.3.4 [29-05-2019] =
194 * Tested : With Latest WordPress & WooCommerce
195 * Fixed : Minor Issues
196
197 = 3.3.3 [27-09-2018] =
198 * Tweaks : Code Cleanup Done.
199 * Tested : With Latest WooCommerce & WordPress
200 = 3.3.2 [12-04-2018] =
201 * Tested : With Latest WooCommerce & WordPress
202 * Fixed : Issue With WC Importer
203 * Tweaks : Minor Bug Fixed
204 * Tweaks : CodeCleanUP Done.
205
206 = 3.3.1 [12-03-2018] =
207 * Tweaks : Code CleanUP done.
208 * Tested : Checked With latest WC Version
209 * Tested : Checked With Latest WP Version
210
211 = 3.3 [01-03-2018] =
212 * Added : Option To Clear Cache Of Variation in product edit view.
213 * Fixed : Pricing Issue
214 * Tweaks : Formated Source Code
215 * Tweaks : Improved Variable Caching Methods.
216
217 = 3.2.4 [14-12-2017] =
218 * Fixed : Variation Product Showing Base price if product role price set to 0
219 * Tweaks : Minor Bug Fixes
220
221 = 3.2.3 [14-12-2017] =
222 * Fixed : Variation Product Showing Base price if product role price set to 0
223 * Tweaks : Minor Bug Fixes
224
225 = 3.2.2 [29-11-2017] =
226 * Fixed : Variation Product Showing 0 (Updated--);
227
228 = 3.2.1 [29-11-2017] =
229 * Fixed : Variation Product showing 0 (https://wordpress.org/support/topic/v3-2-problem-variable-products)
230 * Tweaks : Minor Code Changes
231
232 = 3.2 [28-11-2017] =
233 * Tweaks : Removed Unwanted Codes & Codeclean Up Done
234 * Tweaks : Improved Speed & Stability For Variation Products
235 * Tweaks : Overall Plugin Speed Improved
236 * Tweaks : Minor Bug Fixed
237
238 * Added : Added Cache For Variation Pricing
239 * Added : Tested With Latest WP & WC
240
241 = 3.1 [07-07-2017] =
242 * Added : New Integration With WC Default Product Exporter
243 * Added : New Integration With WC Default Product Importer
244 * Fixed : Minor Tweaks Done.
245
246 = 3.0.9 [31-05-2017] =
247 * Fixed : Fatal Error Below WC 3.0.
248
249 = 3.0.8 [19-05-2017] =
250 * Tweaks : Removed Old & Unwated Codes
251 * Tweaks : Improved Stability With WC 3.0
252 * Tweaks : Reducded DB query for product prices more than once
253 * Tweaks : Addon : Improved Integration With Aelia Currency Switcher
254
255 = 3.0.7 [15-05-2017] =
256 * Fixed : Improved Stability With WC 3.0
257 * Fixed : Changes Settings Framework A Bit
258 * Fixed : Minor Changes Done.
259
260 = 3.0.6 [18-04-2017] =
261 * Fixed : Tax Issue in variable product with WC 3.0
262 * Fixed : Sale Price display issue with WC 3.0
263
264 = 3.0.5 [13-04-2017] =
265 * Fixed : Issues With WooCommerce 3.0.1
266 * Tweaks : Improved Plugin With WC 3.0.1
267 * Fixed : Minor Bug Fixed.
268
269 = 3.0.4 [23-03-2017] =
270 * Fixed : Currency Price issue with Aelia Currency Switcher.
271
272 = 3.0.3 [10-03-2017] =
273 * Fixed : Variation Selectbox auto removed after selecting variations.
274 * Tweaks : Changed Some Core Codes.
275
276 = 3.0.2 [08-02-2017] =
277 * Fixed : Tax Price issue in variable product. tax getting add 2 times in base price.
278 * Tweaks : WC RBP Metabox Code Tweaked
279 * Tweaks : Improved WPML Integration
280 * Fixed : Minor Issues
281 * Tweaks : Minor Core Updates
282
283 = 3.0.1 [26-01-2017] =
284 * Fixed : Parse error: syntax error, unexpected '.', expecting ',' or ';' in ../includes/helpers/class-admin-notice.php on line 6 [https://wordpress.org/support/topic/output-error-after-update/]
285
286 = 3.0 [26-01-2017] =
287 * Total Plugin Redeveloped
288 * Tested With latest WordPress & WooCommerce
289 * Made It Developer Friendly
290 * Easy To Create Addons
291 * 5+ Plugins Integrated
292
293 = 2.8.8 [28-01-2016] =
294 * Tweak : Recoded for the frontend price
295 * Fixed : Price issue with the version 2.8.7 which aelia currency switcher active. is now fixed and minor fix
296 = 2.8.7 [06-01-2016] =
297 * Fixed : Price issue with the version 2.8.6 or below. which aelia currency switcher active. is now fixed and minor fix
298
299 = 2.8.6 [04-01-2016] =
300 * Fixed : Price not showing after the update
301
302 = 2.8.5 [04-01-2016] =
303 * Fixed : Set 0 Price for a product [https://wordpress.org/support/topic/zero-price-3?replies=12]
304
305 = 2.8.4 [01-12-2015] =
306 * Fixed : Products in currencies come up with wrong prices [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/20]
307 * Fixed : Aelia Currency Switcher options not available in wp-all-import template [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/19]
308
309 = 2.8.3 [12-11-2015] =
310 * Fixed : Variation pricing not showing properly {https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/17}
311 * Minor Bug Fixes
312
313 = 2.8.2 [09-11-2015] =
314 * Fixed : Selling Price Not Showing As Per Role Based Price Settings {https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/16}
315 * Minor Bug Fix
316
317 = 2.8.1 [08-11-2015] =
318 * Fixed : Selling / Regular shown from base product price if any one is empty [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/14]
319 * Updated : Persian Language
320
321 = 2.8 [08-11-2015] =
322 * Fixed : Selling / Regular shown from base product price if any one is empty [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/14]
323 * Fixed [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/12]
324 * Bulk Variable Price Edit In Product Edit View
325 [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/11]
326 * Added Persian translation [https://github.com/technofreaky/WooCommerce-Role-Based-Price/issues/15]
327 * Updated POT File
328 * Minor Bug Fix
329
330 = 2.7.4 [04-11-2015] =
331 * Fixed https://wordpress.org/support/topic/error-676?replies=2#post-7625400
332 * Minor Bug Fix
333
334
335 = 2.7.3 [04-11-2015] =
336 * Fixed WooCommerce Product Addons Integration Activation
337 * Minor Bug Fix
338
339 = 2.7.2 [04-11-2015] =
340 * Added User Configurable Option For Price & Product Hide
341 * User Configurable Option to hide variations or with add-to-cart button for variable
342 * Minor Bug Fix
343
344 = 2.7.1 [03-11-2015] =
345 * Fixed Variable Add To Cart Form Hidden.
346 * Minor Bug Fix
347
348 = 2.7 [21-10-2015] =
349 * Added Support Addon For WooCommerce Product Addons
350 * Minor Bug Fix
351
352 = 2.6 [10-10-2015] =
353 * Fixed Price output when using custom separator.
354 * Minor bug fix
355
356 = 2.5 [30-09-2015] =
357 * Code Clean Up
358 * Changed Addons Activation & Deactivation Stucture
359 * Fixed Price Seperator Issue [https://wordpress.org/support/plugin/woocommerce-role-based-price]
360 * Redeveloped Aelia CurrencySwitcher Integration
361 * Minor House Keeping
362 * Updated To Latest Version WordPress
363 * Updated To Latest Version WooCommerce
364
365 = 2.4 [16-09-2015] =
366 * Fixed POPUP Loading Issue With Variable Products.
367 * Minor Bug Fix With Aelia Currency Switcher Integration
368 * Code Cleanup
369 * Added Option Get Product's Base Regular & Selling Price Using Shortcode
370
371 = 2.3 [14-09-2015] =
372 * Fixed POPUP Loading Issue.
373
374 = 2.2 [13-09-2015] =
375 * Changed POPUP View In Product Edit Page
376 * Product Price Not Showing Correctly When Saved As Empty Field Fixed
377 * Added Shortcode to get product price.
378 * Minor Bug Fix
379
380 = 2.1 [05-09-2015] =
381 * Fixed Hide Price Issue When No User LogedIn
382 * Fixed Hide Add-to-cart issue when no user logedIn
383 * Made Plugin Compatible With WP Multisite
384 * Minor Bug Fix
385
386 = 2.0 [03-09-2015] =
387 * Total Plugin ReDeveloped
388 * Added Integrations To WP All Import Plugin
389 * Added Integration To Aelia Currency Switcher Plugin
390 * Updated Code Standards
391 * Update Plugin For Latest WP & WooCommerce (WP : 4.3 | WC : 2.4.6)
392 * Minor Bug Fix
393
394 = 1.3 [25-06-2015] =
395 * Major Update [Had Some File Conflict.. please update your plugin too]
396
397 = 1.2 [23-06-2015] =
398 * Fixed Error Message at product price when viewing as visitor
399
400 = 1.1 [23-06-2015] =
401 * Fixed Simple & Variation Product Price At Checkout & Cart Page
402 * Code CleanUP
403 * Fixed Minor Issue
404 * Fixed Variation Role Based Box in Product Edit Page
405 * Added Plugin Translation Files [wc-rbp]
406
407 = 1.0 [22-06-2015] =
408 * Added Role Based Pricing For Variable / Variation Product [<a href="https://wordpress.org/support/topic/for-variation-products-1?replies=13"> For variation products </a> ]
409 * Fix Major Bugs
410 * Update Plugin For Latest WP & WooCommerce (WP : 4.2.2 | WC : 2.3.11)
411 * Option To Rename User Role (Affected Only For This Plugin) [<a href="https://wordpress.org/support/topic/rename-titles?replies=2"> Rename titles </a> ]
412
413 = 0.2 [26-02-2015] =
414 * Fixed Selling Price Display for role based Issue At [<a href="https://wordpress.org/support/topic/excellent-plugin-but-has-a-small-bug?replies=4#post-6620252">#6620252</a>]
415
416 = 0.1 [25-02-2015] =
417 * Base Version
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Summary (no period for file headers)
4 *
5 * Description. (use period)
6 *
7 * @link https://wordpress.org/plugins/woocommerce-role-based-price/
8 * @package Role Based Price For WooCommerce
9 * @subpackage Role Based Price For WooCommerce/core
10 * @since 3.0
11 */
12 if( ! defined('WP_UNINSTALL_PLUGIN') ) {
13 exit;
14 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * Plugin Name: Role Based Price For WooCommerce
4 * Plugin URI: https://wordpress.org/plugins/woocommerce-role-based-price/
5 * Description: Sell product in different price for different user role based on your settings.
6 * Version: 3.3.6
7 * Author: Varun Sridharan
8 * Author URI: http://varunsridharan.in
9 * License: GPL-2.0+
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 * Text Domain: woocommerce-role-based-price
12 * Domain Path: /languages/
13 */
14
15 if ( ! defined( 'WPINC' ) ) {
16 die;
17 }
18
19 define( 'WC_RBP_FILE', plugin_basename( __FILE__ ) );
20 define( 'WC_RBP_PATH', plugin_dir_path( __FILE__ ) ); # Plugin DIR
21 define( 'WC_RBP_INC', WC_RBP_PATH . 'includes/' ); # Plugin INC Folder
22 define( 'WC_RBP_DEPEN', 'woocommerce/woocommerce.php' );
23 define( 'WC_RBP_VARIABLE_VERSION', '3.3.6' );
24 register_activation_hook( __FILE__, 'wc_rbp_activate_plugin_name' );
25 register_deactivation_hook( __FILE__, 'wc_rbp_deactivate_plugin_name' );
26 register_deactivation_hook( WC_RBP_DEPEN, 'wc_rbp_dependency_plugin_deactivate' );
27
28
29 /**
30 * The code that runs during plugin activation.
31 * This action is documented in includes/class-plugin-name-activator.php
32 */
33 function wc_rbp_activate_plugin_name() {
34 require_once( WC_RBP_INC . 'helpers/class-activator.php' );
35 woocommerce_role_based_price_Activator::activate();
36 }
37
38 /**
39 * The code that runs during plugin deactivation.
40 * This action is documented in includes/class-plugin-name-deactivator.php
41 */
42 function wc_rbp_deactivate_plugin_name() {
43 require_once( WC_RBP_INC . 'helpers/class-deactivator.php' );
44 woocommerce_role_based_price_Deactivator::deactivate();
45 }
46
47
48 /**
49 * The code that runs during plugin deactivation.
50 * This action is documented in includes/class-plugin-name-deactivator.php
51 */
52 function wc_rbp_dependency_plugin_deactivate() {
53 require_once( WC_RBP_INC . 'helpers/class-deactivator.php' );
54 woocommerce_role_based_price_Deactivator::dependency_deactivate();
55 }
56
57 require_once( WC_RBP_INC . 'functions.php' );
58 require_once( plugin_dir_path( __FILE__ ) . 'bootstrap.php' );
59
60 if ( ! function_exists( 'woocommerce_role_based_price' ) ) {
61 function woocommerce_role_based_price() {
62 return woocommerce_role_based_price::get_instance();
63 }
64 }
65 woocommerce_role_based_price();
...\ No newline at end of file ...\ No newline at end of file
1 <wpml-config>
2 <custom-fields>
3 <custom-field action="copy">_enable_role_based_price</custom-field>
4 <custom-field action="copy">_role_based_price</custom-field>
5 </custom-fields>
6 </wpml-config>
...\ No newline at end of file ...\ No newline at end of file